STM32H7 UART DMA Receive unknown length of data.
I use STM32H753 and USART1 with DMA to receive data of unknown length (Min: 8 bytes Max: 512 bytes) from PC. Data will be sent in burst after every one second. My baud rate is 9600. So approx 1ms per byte.
So, maximum, I'm going to get all the data in 512 ms and I'm free to analyze the data for another 488 ms.So, I want some algorithm so that I can parse all data (Min: 8 bytes Max: 512 Bytes) on DMA after all data received.
I am using follwoing methods.
1) Receiving without DMA and interrupt on every byte.
-> Working fine. But the more CPU interference required.
2) Receiving with Half and Full transfer interrupt with DMA.
-> Working fine but sometime we need to wait for one second (or more than that, depending upon buffer size) till the filling the buffer (HALF or FULL). It makes the communication process slower.
3) Receiving with DMA_CIRCULAR with DMA and keep eye on NDTR of DMA Stream.
-> Working fine but sometime we get error because NDTR updates first after receiving data in UART peripheral. And then DMA will copy data into memory.
4) Receiving with DMA_NORMAL with DMA and using "HAL_UARTEx_ReceiveToIdle_DMA"
-> Working fine but some time call back calls (with "Size") before actual data received in memory. Same problem as point no 3.
So please suggest best method for my case.
