Skip to main content
DWann
Associate III
September 4, 2020
Solved

CubeMX: ADC and DMA initialized in the wrong order

  • September 4, 2020
  • 7 replies
  • 2596 views

STM32L010C6Tx

STM32CubeMX V 5.4.0

FW_L0 V1.11.2

When creating a new project that used the ADC with the DMA and some unrelated peripherals, cubeMX will generate the following initialization list in main:

 /* Initialize all configured peripherals */
 MX_ADC_Init();
 MX_DMA_Init();
 MX_TIM2_Init();
 MX_TIM21_Init();
 MX_GPIO_Init();
 /* USER CODE BEGIN 2 */

This is a bug - MX_DMA_Init() should be called before MX_ADC_Init(). The ADC init function will attempt to write the the DMA CCR1 register, but will fail because the DMA has not yet been initialized.

This topic has been closed for replies.
Best answer by Nesrine.JLASSI

Hello @DWann​ 

Please try with the last STM32CubeMX, it correct the issue.

Best regards,

Nesrine

7 replies

Nesrine.JLASSI
Nesrine.JLASSIBest answer
Visitor II
September 7, 2020

Hello @DWann​ 

Please try with the last STM32CubeMX, it correct the issue.

Best regards,

Nesrine

Ondre
Visitor II
August 18, 2021

Hello!

I've still encountered the same bug in STM32CubeIDE Version 1.7.0 for the STM32L100C6. It is however possible to change the initialization order manually inside the advanced settings.

Best regards

André

waclawek.jan
Super User
August 18, 2021

@Community member​ ,

Was this a new project, or you opened an older project with new version of CubeMX?

I understood that the problem was fixed some year ago, but the old .ioc files contain the order established by the old, buggy version of CubeMX.

JW

Ondre
Visitor II
August 18, 2021

Completely new (a few weeks old maybe) project from scratch, but I'll try again, just to be sure.

Stephen28
Associate III
September 16, 2021

I just burned a day figuring this one out.

This project was created about 2 months ago. STM32H743.

Ondre, thanks for the hint that I can change the order in CubeMX Advance Settings.

waclawek.jan
Super User
September 17, 2021
Robin Aproskie
Visitor II
January 19, 2022

This is still a problem in CubeIDE 1.8.0 and FW_L0 1.12.1 took me 2 weeks to find the Issue.