cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H753ZI UART DMA issue

A3
Associate III

I am using UART Receive DMA in circular mode. I am expecting 8 bytes of data to be received on the UART from another device. Hence, I am using "HAL_UART_Receive_DMA(&UartHandle, (uint8_t *)aRxBuffer, 8)". The problem is when a burst of more than 8 bytes of data comes, it overflows to the start of the buffer. In a burst of more than 8 bytes, let's say 5 bytes more. That 5 bytes I want to ignore and don't want that 5 bytes to overflow at start and update the buffer. Please let me know the possible solution. With the present configuration, when USARTx_DMA_RX_IRQHandler is triggered, buffer has already received and overflowed data. How can we keep track that 8 bytes received and how we can avoid updating the buffer for next 5 unwanted bytes

Below is the code snippet to configure UART RX DMA:

 

/* Configure the DMA handler for reception process */

hdma_rx.Instance         = USARTx_RX_DMA_STREAM;

hdma_rx.Init.Direction      = DMA_PERIPH_TO_MEMORY;

hdma_rx.Init.PeriphInc      = DMA_PINC_DISABLE;

hdma_rx.Init.MemInc       = DMA_MINC_ENABLE;

hdma_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;

hdma_rx.Init.MemDataAlignment  = DMA_MDATAALIGN_BYTE;

hdma_rx.Init.Mode        = DMA_CIRCULAR;

hdma_rx.Init.Priority      = DMA_PRIORITY_HIGH;

hdma_rx.Init.FIFOMode      = DMA_FIFOMODE_DISABLE;

hdma_rx.Init.FIFOThreshold    = DMA_FIFO_THRESHOLD_FULL;

hdma_rx.Init.MemBurst      = DMA_MBURST_INC4;

hdma_rx.Init.PeriphBurst     = DMA_PBURST_INC4;

hdma_rx.Init.Request       = USARTx_RX_DMA_REQUEST;

0 REPLIES 0