cancel
Showing results for 
Search instead for 
Did you mean: 

Disable RX TX Callbacks - Uart DMA stop

Posted on December 17, 2015 at 07:21

Hello there,

I am using uart tx and rx with dma. It works, but each time I stop the DMA using:

/**
* @brief Stops the DMA Transfer.
* @param huart: pointer to a UART_HandleTypeDef structure that contains
* the configuration information for the specified UART module.
* @retval HAL status
*/
HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart)
{
/* The Lock is not implemented on this API to allow the user application
to call the HAL UART API under callbacks HAL_UART_TxCpltCallback() / HAL_UART_RxCpltCallback():
when calling HAL_DMA_Abort() API the DMA TX/RX Transfer complete interrupt is generated
and the correspond call back is executed HAL_UART_TxCpltCallback() / HAL_UART_RxCpltCallback()
*/
/* Disable the UART Tx/Rx DMA requests */
huart->Instance->CR3 &= ~USART_CR3_DMAT;
huart->Instance->CR3 &= ~USART_CR3_DMAR;
/* Abort the UART DMA tx Stream */
if(huart->hdmatx != NULL)
{
HAL_DMA_Abort(huart->hdmatx);
}
/* Abort the UART DMA rx Stream */
if(huart->hdmarx != NULL)
{
HAL_DMA_Abort(huart->hdmarx);
}
huart->State = HAL_UART_STATE_READY;
return HAL_OK;
}

The TxCpltCallback and RxCpltCallback interrupts are generated. What would I have to do to disable them, so they wont be generated when I stop DMA? I tried HAL_UART_DMAPause before or HAL_NVIC_DisableIRQ but that did not help. I would really apreciate help.
3 REPLIES 3
Posted on November 16, 2016 at 22:21

Hello there,

I am bumping the thread as I still struggle with this in another project... How can I disable those interrupt when HAL_DMA_STOP is called?

I would really appreciate all help.
Posted on November 17, 2016 at 07:42

My current problem is that now when I Abort DMA I also do:

__HAL_UART_SEND_REQ(uHandle, UART_RXDATA_FLUSH_REQUEST);

To flush what is left and it works. But after this I cant receive any more data through DMA after I do:

HAL_UART_Receive_DMA(uHandle, data, len);

Any ideas?
mark239955_stm1
Associate II
Posted on November 19, 2016 at 11:06

Ignore the HAL and write your own UART+DMA drivers that actually work?

Failing that, read the reference manual sections on the UART and DMA and, with a better understanding of how these peripherals work at a register level, debug the HAL and work out what's going wrong.