cancel
Showing results for 
Search instead for 
Did you mean: 

UART Circular DMA with Idle line callback in STM32MP157

bruno_b2s
Associate II

Hello,

I've implemented the solution proposed in https://github.com/MaJerle/stm32-usart-uart-dma-rx-tx?tab=readme-ov-file 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.

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @bruno_b2s ,

 

As explained during the handling of your internal case, you can take reference from MP13 Uart HAL or H7 to add some HAL API's and use the implementation done by you by taking L4 example.

There is no Hardware limitation to the circular DMA feature, this is supported on STM32MP1.
 

Best Regards,

Kevin

 

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.

View solution in original post

4 REPLIES 4
Olivier GALLIEN
ST Employee

Hi @bruno_b2s 

 

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

Will keep you posted

 

Olivier 

Olivier GALLIEN
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 III

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

https://github.com/karlyamashita/Nucleo-G431RB_Three_UART/wiki

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.

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,

Bruno

Hello @bruno_b2s ,

 

As explained during the handling of your internal case, you can take reference from MP13 Uart HAL or H7 to add some HAL API's and use the implementation done by you by taking L4 example.

There is no Hardware limitation to the circular DMA feature, this is supported on STM32MP1.
 

Best Regards,

Kevin

 

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.