AnsweredAssumed Answered

Long wait for UART_FLAG_TC after DMA transfer

Question asked by The Grue on Oct 25, 2016
Latest reply on Oct 26, 2016 by FTITI.Walid

While implementing a full duplex uart (115kBaud) communication on an STM32F303, I'm struggling quite a bit.

My current problem is that the DMA1_Channel2_IRQn takes 170μs. I'm using DMA to TX data from the STM. Receiving data is handled via interrupt. In the 170μs, two bytes can be received. Since the DMA1_Channel2_IRQn takes so long, the UART Interrupt for receiving is called after these two bytes which results in an overrun error :(

I have attached an oszillogram: 
Ignore yellow(top), 
Red is the duration of UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_TC, RESET, HAL_UART_TXDMA_TIMEOUTVALUE), which is called from DMA1_Channel2_IRQHandler
Blue is Rx data
Green is Tx data
What I don't understand: Why is DMA TC arriving so early (while TXing byte 0x82)? And why does it take so long until the UART TC flag is set?

As you can see on the right side, a DMA_TC is happening while data is received. The RX interrupt can be called only after a byte is lost. How can I handle this? Would nested interrupts solve this problem?

I used the code that has been generated by cube to implement my firmware. I attached the generated code as a ZIP. It's not exactly the same, but I'm not aware of any important changes regarding the DMA/UART.

Any help would be greatly appreciated!