cancel
Showing results for 
Search instead for 
Did you mean: 

512 byte limit with HAL_UARTEx_ReceiveToIdle_DMA

Pincate
Associate III

Hello, I am having a issue with HAL_UARTEx_ReceiveToIdle_DMA on a NUCLEO-H7A3ZI-Q, when using the following code:

uint8_t rx_buffer [4096];
HAL_UARTEx_ReceiveToIdle_DMA(&huart3, rx_buffer, sizeof(rx_buffer));
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t size){
    /*code*/
}

 My rx_buffer is only populating the first 512 bytes, with the remaining data remaining as 0.

__HAL_DMA_GET_COUNTER(huart3.hdmarx);

Provides the incorrect amount of data being passed over serial.

I have used serial plotter and CoolTerm to try and send packets but both hit this 512 byte limit.

Pincate_0-1771425939000.png

rx_buffer not populated past 512 bytes

Pincate_1-1771425954208.png

length correctly calculated as 640 bytes long

11 REPLIES 11
Pincate
Associate III

If I send the following frame receive is equal to 4085 (4096-11)

AA 00 06 08 01 FA 01 FA 02 FA 03
receive = __HAL_DMA_GET_COUNTER(huart3.hdmarx);

But I am not clearing/managing my memory correctly as receive will continue to reduce with each new packet.

Pincate
Associate III

My solution to this issue was using a resettable buffer to copy data from the dma buffer straight to memory before processing it separately. This was in circular mode with fifo disabled as this prevented idle bytes that didn't align to half time or full time events from populating the dma buffer.

for non aligned data I reconfigured the uart settings in stm32h7xx_it.c to manage idle events differently by clearing the idle flag and running a custom function that populates the memory from the rx_buffer.