2024-01-03 02:15 AM
hi,
I want to receive using DMA on STM32H563ZI
The packet size in not fixed. So i plan to receive first two bytes using HAL_UART_Receive_IT.
Once i get the Length Information I can start reception using HAL_UART_Receive_DMA.
If i need to receive 10, bytes then i supply the 20 in Receive DMA function so that i get HT callback, at this point i already have complete data and i can trigger again for Receive_IT till i get length information for next packet.
Currently when i get the HAL_UART_RxHalfCpltCallback, i see that only the last byte of intended buffer is received.
for example if i'm starting DMA for 10 bytes [ 44 49 07 04 00 00 08 5C 54 03], passing 20bytes in Receive_DMA call
then in the HAL_UART_RxHalfCpltCallback i get only the last byte 03.
Also i want to implement Idle line interrupt so that i can use the call back HAL_UARTEx_RxEventCallback, but there is no code generated for HAL_UARTEx_ReceiveToIdle_DMA.
How can i over come this situation.
Is there any other method i can try to get the complete packet by DMA.
STM CubeMX version for H5 Series is 1.1.1 which i believe is the latest version.
Kindly suggest.
2024-01-03 02:50 AM
>The packet size in not fixed. So i plan to receive first two bytes using HAL_UART_Receive_IT.
This is a bad idea. Do continuous receive using cyclic DMA with additional interrupt on receive timeout. Parse chunks of data as they arrive.
> Is there any other method i can try to get the complete packet by DMA
Not really. The DMA controller does not know what is your "complete packet". You need help of the UART (such as character matching, receive timeout).