cancel
Showing results for 
Search instead for 
Did you mean: 

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

SCole.19
Associate II

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?

3 REPLIES 3

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
Up vote any posts that you find helpful, it shows what's working..
SCole.19
Associate II

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
Associate II

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.