Skip to main content
ron239955_stm1
Associate III
June 19, 2013
Question

STM32F4 - DMA to UART Tx, can I stick a byte in the front of the queue?

  • June 19, 2013
  • 2 replies
  • 673 views
Posted on June 19, 2013 at 08:02

I have an STM32F4 project that uses DMA for UART transmission, and it's working well. I now need to add the ability to interrupt the DMA process and send a single byte immediately (or, more specifically, once the byte that's currently being transmitted is complete). The goal is to get this character out ASAP without losing any of the data in the DMA buffer - everything in the buffer still needs to get sent.

Does anyone know if this is possible, and if so, is there a ''right'' way to do it?

#stm32f4-uart-dma-tx
This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
June 19, 2013
Posted on June 19, 2013 at 17:00

I'm pretty sure you'd just need to modulate the enable/disable for the DRQ

  /* Disable the USART Tx DMA request */

  USART_DMACmd(UART5, USART_DMAReq_Tx, DISABLE);

..

wait for TXE, send asych char

..

  /* Enable the USART Tx DMA request */

  USART_DMACmd(UART5, USART_DMAReq_Tx, ENABLE);

Just hope you're receiving device can figure out the interruption in the stream.
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
ron239955_stm1
Associate III
June 19, 2013
Posted on June 19, 2013 at 20:12

Thanks very much! I was hoping it was something simple like that. I will give it a shot and report back.

The protocol I'm working with (MIDI, in case anyone's interested) defines special ''real time'' bytes that can (and should) interrupt transmission at any time. They're used for timing among other things, hence the need to get them out on an exact schedule, regardless of whatever else is going on.