2022-04-02 08:37 AM
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
Solved! Go to Solution.
2022-04-07 04:18 AM
Hello @Shen
Thank you for your contribution.
This issue has been reported internally.
Internal ticket number: 126032 (PS: This is an internal tracking number and is not accessible or usable by customers)
BeST Regards,
Walid
2022-04-04 04:05 AM
Hello Shen,
In order to allow a better analysis of your problem, could you please give us the .ioc file that you are used to reproduce this issue.
BeST Regards,
Walid
2022-04-05 07:27 AM
2022-04-07 04:18 AM
Hello @Shen
Thank you for your contribution.
This issue has been reported internally.
Internal ticket number: 126032 (PS: This is an internal tracking number and is not accessible or usable by customers)
BeST Regards,
Walid