cancel
Showing results for 
Search instead for 
Did you mean: 

BUG in STM32CubeMX struct initialization

utelettronico2
Associate
Posted on June 10, 2016 at 11:39

Hello,

I noticed that the STM32CubeMx doesn't generate default struct initialization in the code. This doesn't usually raise an error because all fields are tipically initialized, but sometimes this doesn't apply. I.E in MX_ADC1_Init:

ADC_MultiModeTypeDef multimode;
 /**Configure the ADC multi-mode 
 */
 multimode.Mode = ADC_MODE_INDEPENDENT;
 if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
 {
 Error_Handler();
 }

these lines cause an error because sometime the other two fields DMAAccessMode and TwoSamplingDelay aren't initialized at 0 as supposed. The correct solution is a default initializatio for the struct:

ADC_MultiModeTypeDef multimode = {0};

as in the examples in the various STM32Cube_FW_*. Regards #cubemx
1 REPLY 1
Amel NASRI
ST Employee
Posted on June 10, 2016 at 11:57

Hi dallagiovanna.luca,

I confirm this bug that concerns STM32L4. Please note that it will be fixed in next CubeMX version.

-Mayla-

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.