cancel
Showing results for 
Search instead for 
Did you mean: 

How to use HAL to leave the UART DMA in idle mode?

mur
Associate III

Hi,

I'm trying to develop a module where information from a buffer is read by DMA and sent through UART, but the information is put in the buffer without a constant rate and it might happen that the buffer is empty, if that happened, I understand that the DMA would keep working sending information which has already been sent.

Then my initial idea is to check whether the buffer has more information in the HAL_UART_TxCpltCallback() and in case that there is no more information disable it, and whenever there's data in the buffer, call HAL_UART_Transmit_DMA.

I've seen HAL_UART_DeInit, but I'm also using the uart RX and then I think both RX and TX would stop working, which is not ok for me.

Then, what do you suggest for tackling this issue?

Best regards,

Nicolas.

1 ACCEPTED SOLUTION

Accepted Solutions
mur
Associate III

DFuchs, thanks for your answer.

For any other person with the same issue, the conclusion is that if the DMA is configured in normal mode, the transmission just ends so the user does not have to disable it.

View solution in original post

2 REPLIES 2
DFuchs
Associate III

Hi,

i can only speak about the STM32H743.

When i'm starting an DMA transfer (memory to peripheral) i set the number of data to transmit (register DMA_SxNDTR). When this register reaches zero i can send the next data.

mur
Associate III

DFuchs, thanks for your answer.

For any other person with the same issue, the conclusion is that if the DMA is configured in normal mode, the transmission just ends so the user does not have to disable it.