cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX 6.5.0 code generation error when ADC enables temperature sensor�?Vref and Vbat channel(LL library)

Shen
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

3 REPLIES 3

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

Shen
Associate II

Hello Walid,

Thank you for your reply, here is my .ioc file.

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