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

kurta999
kurta999Author
Senior
March 21, 2019

Any news please?

kurta999
kurta999Author
Senior
April 17, 2019

Any news on this issue?

kurta999
kurta999Author
Senior
April 26, 2019

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

Jeff Gros
Associate II
April 26, 2019

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

kurta999
kurta999Author
Senior
October 1, 2019

Any news on this please?

Khouloud ZEMMELI
ST Employee
October 2, 2019

​Hello @kurta999​ ,

Could you please share your ioc file?

Best Regards,

Khouloud.

WilkoL
Senior
March 10, 2021

Just wasted a few hours on this, so it STILL isn't fixed.

This (generated by CubeMX) does not work:

LL_ADC_REG_SetSequencerChAdd(ADC1, LL_ADC_CHANNEL_TEMPSENSOR);
LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(ADC1), LL_ADC_PATH_INTERNAL_TEMPSENSOR);
 
LL_ADC_REG_SetSequencerChAdd(ADC1, LL_ADC_CHANNEL_VREFINT);
LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(ADC1), LL_ADC_PATH_INTERNAL_VREFINT);

But this does:

LL_ADC_REG_SetSequencerChAdd(ADC1, LL_ADC_CHANNEL_TEMPSENSOR);
LL_ADC_REG_SetSequencerChAdd(ADC1, LL_ADC_CHANNEL_VREFINT);
 
LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(ADC1), LL_ADC_PATH_INTERNAL_TEMPSENSOR | LL_ADC_PATH_INTERNAL_VREFINT);

kurta999
kurta999Author
Senior
October 3, 2019

Here is it:

Khouloud ZEMMELI
ST Employee
October 3, 2019

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

Best Regards,

Khouloud.

kurta999
kurta999Author
Senior
October 4, 2019

Thanks!

kurta999
kurta999Author
Senior
May 31, 2020

Any news on this? I'm working with F4 now and it's also present here not only for L4.

Senior II
June 7, 2022

Any news on this? I'm working with the up-to-date framework / tools and still not fixed for F7.

(Same bug reported here: https://community.st.com/s/question/0D50X0000C20aDzSQI/bug-cubemx-550-stm32g0-wrong-setcommonpathinternalch-initialization )

Edit: On the F767xx this a bit more complicated. While chapters 15.10 and 15.11 of the reference manual (RM0410) state that only VBAT and internal temperature sensor can't be used at the same time.

Reality shows and register description of ADC_CCR state that VBAT can't be used with temperature sensor OR VREFINT at the same time.

I suggest a fix of the reference manual (update the chapter 15.11 note) and maybe a warning when generating invalid combinations with CubeMX.

Motla1
Associate
February 9, 2023

@Khouloud ZEMMELI​ Any news on this ?? It's crazy that it has to take ST more than 4 years to correct such a simple bug like this... Very annoying for anybody during all this time who spend hours to understand what is wrong with your libraries, because someone doesn't want to correct it.

Khouloud ZEMMELI
ST Employee
February 16, 2023

@Motla​ , First I want to apologize for the delay made to fix this issue, @Khouloud OTHMAN​ Could you please take in charge the follow up of that issue (or one of the support team) as I don't work on support anymore?

werbung
Associate II
January 27, 2025

@Khouloud OTHMAN​  Any news  ?  Problems still exists.  Still pending in CubeMX even in STM32H5xx.