Skip to main content
kurta999
Senior
Mar 11, 2019 12:37 PM UTC
Question

STM32CubeMX LL_ADC_SetCommonPathInternalCh generation bug - only one internal ch is enabled

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

This topic has been closed for replies.

16 replies

kurta999
kurta999Author
Senior
Mar 21, 2019 6:08 AM UTC

Any news please?

kurta999
kurta999Author
Senior
Apr 17, 2019 7:26 AM UTC

Any news on this issue?

kurta999
kurta999Author
Senior
Apr 26, 2019 7:09 AM UTC

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

Jeff Gros
Associate II
Apr 26, 2019 6:07 PM UTC

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

kurta999
kurta999Author
Senior
Oct 1, 2019 8:19 AM UTC

Any news on this please?

Khouloud ZEMMELI
ST Employee
Oct 2, 2019 3:26 PM UTC

​Hello @kurta999​ ,

Could you please share your ioc file?

Best Regards,

Khouloud.

WilkoL
Senior
Mar 10, 2021 4:36 PM UTC

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
Oct 3, 2019 7:17 AM UTC

Here is it:

Khouloud ZEMMELI
ST Employee
Oct 3, 2019 9:34 AM UTC

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

Best Regards,

Khouloud.

kurta999
kurta999Author
Senior
Oct 4, 2019 6:12 AM UTC

Thanks!

kurta999
kurta999Author
Senior
May 31, 2020 4:01 PM UTC

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

Senior II
Jun 7, 2022 12:02 PM UTC

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.

When this account seems to be inactive, try @tdecker2 - ST can't change mail addresses, so I had to create a new account.
Motla1
Associate II
Feb 9, 2023 1:12 PM UTC

@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
Feb 16, 2023 8:58 AM UTC

@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
Jan 27, 2025 9:38 PM UTC

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