Skip to main content
Ben K
Senior III
November 9, 2021
Solved

STM32CubeIDE generates wrong peripheral init sequence when using DMA

  • November 9, 2021
  • 2 replies
  • 1116 views

Hi there!

I have configured an STM32L432KC Nucleo board in STM32CubeIDE, with UART2 and TIM2 using DMA. The generated code doesn't set up these DMAs correctly. The root cause is that their MX_<peripheral>_Init() calls precede the MX_DMA1_Init(), and the MspInit() of these two peripherals initialize DMA channels at a time when the RCC clock for the DMA isn't enabled. The project setup is available here for reproducing the problem: https://github.com/benedekkupper/ProntoInfrared/tree/bc8280e38ce5fb5fe04d3c918bf8fa2542a05964

This topic has been closed for replies.
Best answer by Louis Cloete

This was fixed and regressed recently again. See https://community.st.com/s/question/0D50X0000Bmob3uSQA/dma-not-working-in-cubemx-generated-code-order-of-initialization

In the mean time, you can reorder the functions in CubeMX. See UM1718 STM32CubeMX for STM32 configuration and initialization C code generation section 4.9.3 Advanced Settings Tab: Ordering initialization function calls on page 139.

2 replies

Amel NASRI
ST Technical Moderator
November 16, 2021

Hi @Ben K​ ,

Thanks for sharing your experience.

Unfortunately, this is a known issue faced with STM32CubeMX 6.3.

Our STM32CubeMX team is already aware about it. A fix should be available in next revision of the tool (we expect it to be available soon).

-Amel

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.
Louis Cloete
Louis CloeteBest answer
Associate II
November 16, 2021

This was fixed and regressed recently again. See https://community.st.com/s/question/0D50X0000Bmob3uSQA/dma-not-working-in-cubemx-generated-code-order-of-initialization

In the mean time, you can reorder the functions in CubeMX. See UM1718 STM32CubeMX for STM32 configuration and initialization C code generation section 4.9.3 Advanced Settings Tab: Ordering initialization function calls on page 139.