Skip to main content
SCole.19
Associate
May 16, 2019
Question

How to check when Usart Tx is complete after DMA memory to Usart transfer?

  • May 16, 2019
  • 3 replies
  • 1258 views

STM32F334K6

I am using LL_DMA memory to Usart function to transmit DMX data, and using the DMA_TransmitComplete interrupt to trigger the DMX break signal.

This interrupt occurs before the last two bytes have been sent by the Usart, so the DMX frame is two bytes short.

Can the Usart trigger an interrupt when it has finished sending all the data from the DMA?

I tried using the Tx_Complete and Tx_Empty flags but the whole frame turns to garbage when trying to use these. Are these flags suitable for this purpose?

This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
May 16, 2019

The TC bit on the USART should indicate all data has crossed the wire, look at both TXE and TC

The 2-byte early issue here is due to one data in the shift-register and one in the transmit holding buffer, give-or-take a bit based on the latency of the DMA service.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
SCole.19
SCole.19Author
Associate
May 17, 2019

Many thanks for the answer. I kinda guessed my first attempt at using the TXE & TC flags failed because of incorrect code. I will try again

SCole.19
SCole.19Author
Associate
May 17, 2019

Okay, I was being completely dumb about this. All I had to do was use the DMA_TransmitComplete interrupt to enable the Usart TransmitComplete interrupt and then disable the Usart int again before the break and I get a full DMX frame transmitted.