Showing results for 
Search instead for 
Did you mean: 

UART Circular DMA with Idle line callback in STM32MP157

Associate II


I've implemented the solution proposed in by @Tilen MAJERLE for efficiently using the DMA in circular mode with a buffer for the UART in a STM32L4 board.

I'm trying to port my driver to the M4 processor of a STM32MP157-DK2. I've successully configured the UART3 in the M4 project with DMA in normal mode and I'm receiving one byte at a time and adding them with the RxComplete callback to my buffer.

However, when I changed the DMA mode to circular, my surprise was that there is no HAL_UARTEx_ReceiveToIdle_DMA function in the HAL driver and no HAL_UARTEx_RxEventCallback callback. So I can use the RxComplete and RxHalfComplete callbacks but no idle line callback, which is a big problem when using a long circular buffer size.

Can anyone explain what is the problem, why there is no Idle line detection here or how can this feature be implemented for this board?


Thanks in advance.

ST Employee

Hi @bruno_b2s 


An internal case #BZ176781 has been open to address this point

Will keep you posted



In order 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.
Karl Yamashita
Lead II

Skip using the Circular buffer and implement your own buffer queue that you point the DMA to. That way you don't have to keep copying the data to another array. It's all done by the DMA. You can just use the half complete callback and not bother with Full Complete callback. 

See this project which explains more about it

Thanks for your reply @Karl Yamashita. I think the problem is not setting the UART DMA in Normal or Circular mode - although in my opinion using circular mode helps saving CPU time. The problem is that with the generated code for a STM32MP157-DK2, I can't use HAL_UARTEx_ReceiveToIdle_DMA or HAL_UARTEx_RxEventCallback. They simply don't exist in the generated drivers.

I see in your wiki (very interesting by the way, I'm using a similar wrap-up but with less features, trying to imitate Arduino Serial), that you use these functions too. So my question to ST is @Olivier GALLIEN : why these functions are not there? how can I use the Idle callback without them?

Best regards,