cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX LL_ADC_SetCommonPathInternalCh generation bug - only one internal ch is enabled

kurta999
Senior

I can't measure tempsensor with vbat and vref because cubemx generates low layer code in the following order:

LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_6, LL_ADC_CHANNEL_TEMPSENSOR);
  LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_TEMPSENSOR, LL_ADC_SAMPLINGTIME_640CYCLES_5);
  LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_TEMPSENSOR, LL_ADC_SINGLE_ENDED);
  LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(ADC1), LL_ADC_PATH_INTERNAL_TEMPSENSOR);
  /** Configure Regular Channel 
  */
  LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_7, LL_ADC_CHANNEL_VREFINT);
  LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_VREFINT, LL_ADC_SAMPLINGTIME_640CYCLES_5);
  LL_ADC_SetChannelSingleDiff(ADC1, LL_ADC_CHANNEL_VREFINT, LL_ADC_SINGLE_ENDED);
  LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(ADC1), LL_ADC_PATH_INTERNAL_VREFINT);  // Previously enabled tempsensor bit get overwritten here and only internal vrefint channel is enabled.. I took a few hours until I figured out why ny MCU temp measuring module isn't works since I ported my ADC to HAL from LL

Finaly result is only vrefint is enabled and tempsensor is disabled. CubeMX should use logical OR in this case. In HAL it is implemented correctly, but this implementation missing from LL.

Solution is:

LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(ADC1), LL_ADC_PATH_INTERNAL_TEMPSENSOR | LL_ADC_PATH_INTERNAL_VREFINT);

14 REPLIES 14
kurta999
Senior

Any news please?

kurta999
Senior

Any news on this issue?

kurta999
Senior

Please look after this bug,. it's still present with CubeMX 5.2.0.

Jeff Gros
Associate II

Just adding my name to the thread so I can track this.

kurta999
Senior

Any news on this please?

Khouloud ZEMMELI
ST Employee

​Hello @kurta999​ ,

Could you please share your ioc file?

Best Regards,

Khouloud.

kurta999
Senior

Here is it:

​Thanks for the feedback, this's reported internally for further check.

Best Regards,

Khouloud.

Thanks!