cancel
Showing results for 
Search instead for 
Did you mean: 

How to use UART DMA RX?

JLEE.211
Associate

Hello.

I developed UART by DMA method and it works normally, but I am posting because I have one question.

In the case of the sites I found, most of the main function or initial HAL_UART_Receive_DMA function was called, and the HAL_UART_RxCpltCallback function also called HAL_UART_Receive_DMA. So I also wrote the same.

I thought the reason for doing so was to make the DMA controller listen again. So I thought that the HAL_UART_RxCpltCallback function also calls the HAL_UART_Receive_DMA function.

However, UART works normally without calling HAL_UART_Receive_DMA in HAL_UART_RxCpltCallback. Can you tell me why?

The environment is:

- STM32F407VE MCU

- FreeRTOS

The referenced implementation is:

0693W00000Y83ErQAJ.png 

Thank you

2 REPLIES 2
KnarfB
Principal III

Are you using circular DMA? What sites have you followed? I recommend https://github.com/MaJerle/stm32-usart-uart-dma-rx-tx

hth

KnarfB

KDJEM.1
ST Employee

Hello @JLEE.21​ and welcome to the Community :),

Are you using an ST example?

You can use HAL_UART_Receive_DMA in HAL_UART_RxCpltCallback function to keep receiving data, otherwise you will only receive it once.

Also, you can add a breakpoint in HAL_UART_Receive_DMA in HAL_UART_RxCpltCallback function to stop the program after data is received, and check rxbuffer.

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Thank you

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.