CubeMX 6.5.0 code generation error when ADC enables temperature sensor�?Vref and Vbat channel(LL library)
Hello Everyone,
I am using STM32G474RE and the STM32CubeMX version is 6.5.0.
When ADC5 enables temperature sensor�?Vref and Vbat channel, STM32CubeMX will generate code in MX_ADC5_Init function(LL library):
/** Configure Regular Channel
*/
LL_ADC_REG_SetSequencerRanks(ADC5, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_VREFINT);
LL_ADC_SetChannelSamplingTime(ADC5, LL_ADC_CHANNEL_VREFINT, LL_ADC_SAMPLINGTIME_2CYCLES_5);
LL_ADC_SetChannelSingleDiff(ADC5, LL_ADC_CHANNEL_VREFINT, LL_ADC_SINGLE_ENDED);
LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(ADC5), LL_ADC_PATH_INTERNAL_VREFINT);
/** Configure Regular Channel
*/
LL_ADC_REG_SetSequencerRanks(ADC5, LL_ADC_REG_RANK_2, LL_ADC_CHANNEL_TEMPSENSOR_ADC5);
LL_ADC_SetChannelSamplingTime(ADC5, LL_ADC_CHANNEL_TEMPSENSOR_ADC5, LL_ADC_SAMPLINGTIME_2CYCLES_5);
LL_ADC_SetChannelSingleDiff(ADC5, LL_ADC_CHANNEL_TEMPSENSOR_ADC5, LL_ADC_SINGLE_ENDED);
/** Configure Regular Channel
*/
LL_ADC_REG_SetSequencerRanks(ADC5, LL_ADC_REG_RANK_3, LL_ADC_CHANNEL_VBAT);
LL_ADC_SetChannelSamplingTime(ADC5, LL_ADC_CHANNEL_VBAT, LL_ADC_SAMPLINGTIME_2CYCLES_5);
LL_ADC_SetChannelSingleDiff(ADC5, LL_ADC_CHANNEL_VBAT, LL_ADC_SINGLE_ENDED);
LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(ADC5), LL_ADC_PATH_INTERNAL_VBAT);
I think there is a line of code missing after line 12:
LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(ADC5), LL_ADC_PATH_INTERNAL_TEMPSENSOR);Besides, calling LL_ADC_SetCommonPathInternalCh() function will clear the previous state, so I think it should be modified to this code:
/** Configure Regular Channel
*/
LL_ADC_REG_SetSequencerRanks(ADC5, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_VREFINT);
LL_ADC_SetChannelSamplingTime(ADC5, LL_ADC_CHANNEL_VREFINT, LL_ADC_SAMPLINGTIME_2CYCLES_5);
LL_ADC_SetChannelSingleDiff(ADC5, LL_ADC_CHANNEL_VREFINT, LL_ADC_SINGLE_ENDED);
/** Configure Regular Channel
*/
LL_ADC_REG_SetSequencerRanks(ADC5, LL_ADC_REG_RANK_2, LL_ADC_CHANNEL_TEMPSENSOR_ADC5);
LL_ADC_SetChannelSamplingTime(ADC5, LL_ADC_CHANNEL_TEMPSENSOR_ADC5, LL_ADC_SAMPLINGTIME_2CYCLES_5);
LL_ADC_SetChannelSingleDiff(ADC5, LL_ADC_CHANNEL_TEMPSENSOR_ADC5, LL_ADC_SINGLE_ENDED);
/** Configure Regular Channel
*/
LL_ADC_REG_SetSequencerRanks(ADC5, LL_ADC_REG_RANK_3, LL_ADC_CHANNEL_VBAT);
LL_ADC_SetChannelSamplingTime(ADC5, LL_ADC_CHANNEL_VBAT, LL_ADC_SAMPLINGTIME_2CYCLES_5);
LL_ADC_SetChannelSingleDiff(ADC5, LL_ADC_CHANNEL_VBAT, LL_ADC_SINGLE_ENDED);
LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(ADC5), LL_ADC_PATH_INTERNAL_VBAT|LL_ADC_PATH_INTERNAL_VREFINT|LL_ADC_PATH_ INTERNAL_TEMPSENSOR);Best regards,
Shen
