cancel
Showing results for 
Search instead for 
Did you mean: 

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

BMeno
Associate

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.

2 REPLIES 2
Mike_ST
ST Employee

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

Herm
Associate III

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