cancel
Showing results for 
Search instead for 
Did you mean: 

Regd HAL_UARTEx_ReceiveToIdle_DMA for STM32H563ZI

SandeepKel
Associate II

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.

1 REPLY 1
Pavel A.
Evangelist III

>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).