Skip to main content
po221
Senior
May 12, 2020
Question

DMA to receive unknown length frames with UART

  • May 12, 2020
  • 4 replies
  • 3108 views

Hi

I need to listen to Rx UART to receive unknown length frames (I will search for a frame start byte, then read the frame size and then test a CRC for frame validating)

I would like to use DMA for performance but I only see half or full reception interrupt of a fixed number of bytes.

Is it possible to do that with DMA or must I using simple interrupts, with 1interrupt for each byte received ?

thanks in advance

PS : I'm using STM32L431 with STM32cubeIDE

This topic has been closed for replies.

4 replies

waclawek.jan
Super User
May 12, 2020

Cube-based, although principle may be usable generally:

https://github.com/MaJerle/stm32-usart-uart-dma-rx-tx

Author is ST FAE.

JW

po221
po221Author
Senior
May 12, 2020
RMcCa
Senior II
May 12, 2020

Dunno about L4s, but F7s have a UART character match interrupt that i have used in conjunction with DMA. If you can terminate the messages with a unique framing character, this method works great. Just stop the DMA in the UART isr and read the NDTR​ and subtract from the initial value to find the number of bytes in the message.

po221
po221Author
Senior
May 12, 2020

L4 reference manual indicates CMIE Character match control bit.

I look for this solution too

Thanks

Tesla DeLorean
Guru
May 12, 2020

Depends if the pattern appears elsewhere in the data stream.

Personally found it easier to use a circular DMA buffer I can sweep on the 1 KHz ticker, or main loop

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
RMcCa
Senior II
May 12, 2020

Thus the reason for the word 'unique' in my response. I use ascii hex to send user commands to my system partially for this reason. 0x0a can only happen at the end of a message. Using ascii hex effectively halves the actual transmission rate in exchange for robustness that is simple and efficient to implement.​