Skip to main content
Ahmad M.Nejad
Associate II
July 29, 2021
Solved

STM32Cube code generator bug for STM32G030J6

  • July 29, 2021
  • 3 replies
  • 1841 views

The generated code has wrong order for MX_DMA_Init() that doesn't work:

 MX_GPIO_Init();

 MX_ADC1_Init();

 MX_DMA_Init();

...

Correct code is:

 MX_GPIO_Init();

 MX_DMA_Init();

 MX_ADC1_Init();

...

note: STM32CubeIDE Version: 1.7.0 Build: 10852_20210715_0634 (UTC)

This topic has been closed for replies.
Best answer by Peter BENSCH

STM32CubeMX does not (yet) know where the function calls should best be placed.

You can manually reorder the generated function calls within STM32CubeIDE (embedded STM32CubeMX) as well as in the standalone STM32CubeMX:

  • on the top select tab Project Manager
  • on the left select Advanced Settings
  • select the function call to be moved, e.g. MX_ADC1_Init();
  • click on the tiny, tiny move button above the blue header of the table (top right) to move it to the desired position

If the problem is resolved, please mark this topic as answered by selecting Select as best. This will help other users find that answer faster.

/Peter

3 replies

Peter BENSCH
Peter BENSCHBest answer
Technical Moderator
July 30, 2021

STM32CubeMX does not (yet) know where the function calls should best be placed.

You can manually reorder the generated function calls within STM32CubeIDE (embedded STM32CubeMX) as well as in the standalone STM32CubeMX:

  • on the top select tab Project Manager
  • on the left select Advanced Settings
  • select the function call to be moved, e.g. MX_ADC1_Init();
  • click on the tiny, tiny move button above the blue header of the table (top right) to move it to the desired position

If the problem is resolved, please mark this topic as answered by selecting Select as best. This will help other users find that answer faster.

/Peter

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.
KMacD.1
Associate
February 11, 2022

This answer is just unacceptable. This issue has made projects frustrating and unprofitable for us. If MXCube doesn't do the right order then it should have a disclaimer to make you aware of this fact.

Kevin

haleecaero.1
Associate II
August 4, 2021

@Peter BENSCH​ if STM32CubeMx doesn't know about that, how is the user supposed to know? Just trial and error until it works, or is there some documentation?

Ahmad M.Nejad
Associate II
August 4, 2021

Cube may be more better, but ST guys freeze its ability to basic!

MichaelSweden
Associate II
August 11, 2021

Thanks for this info. However I notice this by my self, while comparing with my old application for F401. I now tested to create a new project in STM32CubeMX 6.3.0 (with STM32Cube_FW_F4_V1.26.2) for an F401 device and still the order of MX_ADC1_Init() and MX_DMA_Init() is correct. So why is it wrong order in generated code for a G0B1 device?

By the way, I think this is wrong in description of "in case of usage of DMA" in file stm32g0xx_hal_adc.c start at row 115:

 (++) Insert the ADC interruption handler function HAL_ADC_IRQHandler()
 into the function of corresponding DMA interruption vector
 DMAx_Channelx_IRQHandler().

I believe it should be:

 (++) Insert the DMA interruption handler function HAL_DMA_IRQHandler()
 into the function of corresponding DMA interruption vector
 DMAx_Channelx_IRQHandler().

//Michael