2020-05-12 07: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
2020-05-12 08: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
2020-05-12 09: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/
2020-05-12 01: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.
2020-05-12 03:13 PM
L4 reference manual indicates CMIE Character match control bit.
I look for this solution too
Thanks
2020-05-12 03: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
2020-05-12 03: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.