DMA to receive unknown length frames with UART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-05-12 7:11 AM
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
- Labels:
-
DMA
-
STM32F4 Series
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-05-12 8:36 AM
Cube-based, although principle may be usable generally:
https://github.com/MaJerle/stm32-usart-uart-dma-rx-tx
Author is ST FAE.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-05-12 9:18 AM
Thanks a lot
I was reading this from the same author
https://stm32f4-discovery.net/2017/07/stm32-tutorial-efficiently-receive-uart-data-using-dma/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-05-12 1:04 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-05-12 3:13 PM
L4 reference manual indicates CMIE Character match control bit.
I look for this solution too
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-05-12 3:36 PM
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
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-05-12 3:55 PM
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.​
