Question
BUG in STM32CubeMX struct initialization
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