cancel
Showing results for 
Search instead for 
Did you mean: 

DMA UART peripheral Hangs

ra.pamod
Associate III
Posted on September 07, 2017 at 14:25

Hello,

I am using STM32F446 MCU,

I am collecting data from USART2 & transmitting data to USART3. DMA is enabled.

If I make UART RX/TX buffer size to 1024 bytes & transmit data of size 1KB it works fine.

But If I transmit more than 1080 bytes I receive the data on the USART3 terminal but when I send next frame from USART2 I do not get the data on the USART3 terminal. Application traces I can see on the USART3 terminal.

It seems USART2 is locked. If I give query command from USART2 I don't get any reply on USART2.

I am clearing the DMA flags, do I need to clear UART flag.

3 REPLIES 3
Radek RIPA
ST Employee
Posted on September 07, 2017 at 14:47

Hello,

If you are using HAL_UART_Transmit_DMA then it also necessary to enable the IT for UART. Because the transmit in HAL on UART finishes with TC flag on UART not on DMA. Because it can happened that the DMA finishes the transfer but the UART is still sending data. 

You can check the state in uart handle structure in state. Which will be still busy or transmitting. Instead of ready. 

The state clear for TX will be in UART interrupt routine. 

Best regards

Radek

ra.pamod
Associate III
Posted on September 07, 2017 at 15:40

Hello Radek,

Thanks for the reply,

I am not using the HAL library.

I am using the old library of discovery.

In UART read I added UART read flag & if overrun then I am directly reading the UART data register.

This seems to work because now I am sending 14KB data & the UART is still running.

I am not sure if this is the correct way but atleast got the idea that UART register needs to be cleared.

Regards

Pramod

Posted on September 08, 2017 at 08:03

Hello Radek,

To check overrun flag solution didnt work. It only delayed the hang occurrence.

I am using DMA ISR for transmit & receive.

Do I still have to enable the IT for UART to check TC flag.

Should I handle this in DMA isr or before loading data to transmit buffer?

Regards

Pramod