Skip to main content
BMeno
Visitor II
January 13, 2020
Question

Bug report: CubeMX generated ADC with DMA Code broken (wrong init order)

  • January 13, 2020
  • 2 replies
  • 1095 views

Board: NUCLEO-F446RE, STM32F446RE

CubeMX: 5.4.0

If you configure ADC1 with DMA, some configuration code for the DMA is placed into the ADC configuration code (stm32f4xx_hal_msp.c, line 152: if (HAL_DMA_Init(&hdma_adc1) != HAL_OK)).

But in the generated main.c, the DMA clock is switched on after this function is called, i.e. the function MX_DMA_Init() is called after MX_ADC1_Init(). So the configuration of the DMA is not applied, as the DMA is not clocked yet.

A workaround is to swap MX_DMA_Init and MX_ADC1_Init everytime you re-generate the code in CubeMX.

This topic has been closed for replies.

2 replies

Mike_ST
ST Technical Moderator
January 14, 2020

Please check whether you still have this problem with CubeMX 5.5.0.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. 
Herm
Associate II
January 23, 2020

I also experienced this problem. A workaround which does not require you to change the code every time is described here:

https://community.st.com/s/question/0D50X0000C0xoFxSQI/bug-cubemxcubeide-ignores-changes-in-initialization-order