AnsweredAssumed Answered

BUG in STM32CubeMX struct initialization

Question asked by dallagiovanna.luca on Jun 10, 2016
Latest reply on Jun 10, 2016 by Amel N

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)

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_*.