2019-10-04 10:31 AM
I've tried to disable the XferHalfCpltCallback when using UART DMA transmit without any luck. I believe that you cannot change the callbacks, or disable them.
Observations:
Ideas?
2019-10-04 11:51 AM
I guess you need to hack the DMA half transfer interrupt enable control bit yourself.
2019-11-24 08:06 AM
Where should this hack be done?
Sorry, I joined to commiserate more than provide a solution...
I added the hack right after the HAL call:
comms_top_tx_status = HAL_UART_Transmit_DMA(&huart6, tx_packet_ptr, (uint16_t) (COMMS_TOP_TX_PACKET_SIZE));
hdma_usart6_tx.Instance->CR &= ~DMA_IT_HT;
But at this point the DMA is off and running. It looks like a race to disable the interrupt before it fires. It seems to work when I'm doing my long transfers of 30 bytes, but what if the transfer length was short? I'm not even sure it's ok to hack this bit while the xfer is executing.
You could filter execution of your interrupt handler based on the TC (xfer complete) flag. But the problem I'm having is that the second half of the transfer is garbage. So I'm suspicions of the half complete interrupt feature and its handling.
2023-04-12 05:47 AM
A few years late to this, but it looks like the hal_dma still enables the half-transfer interrupt without any clear way to disable it without hacking the hal, as S.Ma mentions. This hack can be done by commenting out the following line in HAL_DMA_Start_IT:
// ((BDMA_Channel_TypeDef *)hdma->Instance)->CCR |= BDMA_CCR_HTIE;
However, I was worried that if our hal was ever updated I'd lose my "fix". So decided to handle the problem in the interrupt instead. Just checking to make sure the full transfer flag has occurred before doing stuff. And ignoring the half-transfer interrupt.
void DMA1_Stream0_IRQHandler(void) {
NVIC_ClearPendingIRQ(DMA1_Stream0_IRQn);
if (__HAL_DMA_GET_FLAG(&m_hdma_spi1_rx, HAL_DMA_GET_TC_FLAG_INDEX(&m_hdma_spi1_rx))) {
// reading is complete, reenable interrupt
HAL_DMA_IRQHandler(&m_hdma_spi1_rx);
do_more_stuff(&m_stuff);
}
}
where m_hdma_spi1_rx is:
static DMA_HandleTypeDef m_hdma_spi1_rx = {
.Instance = DMA1_Stream0,
.Init =
{
.Request = DMA_REQUEST_SPI1_RX,
.Direction = DMA_PERIPH_TO_MEMORY,
.PeriphInc = DMA_PINC_DISABLE,
.MemInc = DMA_MINC_ENABLE,
.PeriphDataAlignment = DMA_PDATAALIGN_BYTE,
.MemDataAlignment = DMA_MDATAALIGN_BYTE,
.Mode = DMA_NORMAL,
.Priority = DMA_PRIORITY_HIGH,
.FIFOMode = DMA_FIFOMODE_DISABLE,
},
};
Hope this is helpful
2023-10-20 07:50 AM
__HAL_DMA_DISABLE_IT(&hdma_usart2_tx,DMA_IT_HT);
2024-08-29 08:56 AM
I seem to be having a similar issue, I am several hours today on it and need to speak out loud!
Basically, I have a half-duplex transceiver connected to USART2:
Is maybe disabling the DMA interrupt on receiving path while transmitting a feasible idea?
2024-08-30 03:16 AM
I reply to myself to clear the statement there and provide solution. Actually it was silly topic and probably not relevant for the previous thread - excuse me!
My issue was:
2024-10-28 07:06 AM
But, as Ron Koch said earlier, it is re-enabled in
HAL_DMA_Start_IT()
and calling
__HAL_DMA_DISABLE_IT()
afterwards would be a race.