Skip to main content
kurta999
Senior
March 11, 2019
Question

STM32CubeMX LL_ADC_SetCommonPathInternalCh generation bug - only one internal ch is enabled

  • March 11, 2019
  • 11 replies
  • 4688 views

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);

11 replies

werbung
Associate II
January 27, 2025

CubeMX  6.9.2    with STM32H5xx

 

Error still exists.   Wasted lots of hours to find out the error.

Vrefint and temp-sensor and VBat  as ADC Channel  in CubeMX  activated.

even though the according Bits "VREFEN , TSEN, VBATEN  in ADC_CCR are always  not set. (Keil debugger)

By manualy activating these bits in the debugger everything works.

IIs there a chance to fix this problem in CUBE MX after 3 Years? 

 

fortunately this helps:

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

 

Thanks  Henry