Skip to main content
WilkoL
Senior
March 10, 2021
Question

Two bugs in LowLayer code for ADC on STM32Lxxx generated by CubeMX

  • March 10, 2021
  • 2 replies
  • 1471 views

The first one is a minor typo I guess. The init code for the ADC has these lines in it:

/* Enable ADC internal voltage regulator */
 LL_ADC_EnableInternalRegulator(ADC);
 /* Delay for ADC internal voltage regulator stabilization. */
 /* Compute number of CPU cycles to wait for, from delay in us. */
 /* Note: Variable divided by 2 to compensate partially */
 /* CPU processing cycles (depends on compilation optimization). */
 /* Note: If system core clock frequency is below 200kHz, wait time */
 /* is only a few CPU processing cycles. */
 uint32_t wait_loop_index;
 wait_loop_index = ((LL_ADC_DELAY_INTERNAL_REGUL_STAB_US * (SystemCoreClock / (100000 * 2))) / 10);
 while(wait_loop_index != 0)
 {
 wait_loop_index--;
 }

The first line should be:

 LL_ADC_EnableInternalRegulator(ADC1);

And the other bug happens when you select both the internal temperature sensor AND the vrefint on the ADC.

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

This bug was already mentioned two years ago by kurta999 in this question:

https://community.st.com/s/question/0D50X0000AU4CvOSQV/stm32cubemx-lladcsetcommonpathinternalch-generation-bug-only-one-internal-ch-is-enabled

This topic has been closed for replies.

2 replies

ST Technical Moderator
March 10, 2021

Hello @Community member​ ,

Thanks for your reported issues.

I added the right topic "STM32CubeMX" in your post to be reviewed by our CubeMX experts @Khouloud OTHMAN​ , @Khouloud ZEMMELI​.

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Khouloud OTHMAN
Associate
March 11, 2021

Hi @Community member​ ,

Thanks for your feedback.

For the first issue you have reported, I can't reproduce it from my side, LL_ADC_EnableInternalRegulator(ADC1) is correctly generated in CubeMX generated code.

Could you please share your .ioc file to investigate the problem ?

For the second point you have raised:

> And the other bug happens when you select both the internal temperature sensor AND the vrefint on the ADC

The problem is already detected and reported to our development team to be reviewed. I will come back to you as soon as possible with updates.

Thank you for your patience.

Khouloud.

WilkoL
WilkoLAuthor
Senior
March 11, 2021

Hello Khouloud,

Thanks for your reply. The problem with the line LL_ADC_EnableInternalRegulator(ADC1) is solved in the latest firmware FW_L0 V1.12.0 .

I noticed that after re-opening the .ioc file STM32CubeMX wanted to upgrade. After letting it do that, it now produces the correct code.

Odd though, is that I do not see that it does upgrade the firmware, see picture.

Wilko0693W000008wcW3QAI.jpg

Khouloud OTHMAN
Associate
March 11, 2021

Hi @Community member​ ,

First let me thank you for the correction of the first problem confirmation :smiling_face_with_smiling_eyes:

To explain briefly the message behind this warning popup: On project load, STM32CubeMX detects if the project was created with an older version of the tool and if this is the case, it proposes the user to either migrate to use the latest STM32CubeMX database and STM32Cube firmware version, or to continue.

You can select continue to use original firmware used at project creation and in this case it will downloaded into your repository as well as the MCU and IPs database, or you can select migrate, and in this case your project will be modified to fit the current database definition.

>Odd though, is that I do not see that it does upgrade the firmware, see picture.

It is a bit odd that this warning window is displayed while working with latest version of firmware. The expected behavior is as in the picture attached below (two different versions of firmware):

0693W000008wd7TQAQ.png 

Could please describe how did you reproduce to get this pop up? It will be really helpful for us to track the root cause of this misbehavior.

Thanks in advance,

Khouloud.