cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in resolution setting when using LL for ADC3

mkm_ctv
Associate II

As indicated in community.st.com/s/question/0D53W00000zoHteSAE/h7cubemx-critical-bugs-with-ll-and-adc3 there seems to have been a bug where the resolution wasn't correctly set when working with ADC3.

As of today, the conversion seems to instead be made twice, both in the calling code (generated by CubeMX)

ADC_InitStruct.Resolution = __LL_ADC12_RESOLUTION_TO_ADC3(LL_ADC_RESOLUTION_10B);
  ADC_InitStruct.LowPowerMode = LL_ADC_LP_MODE_NONE;
  LL_ADC_Init(ADC3, &ADC_InitStruct);

and in the library code

ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct)
{
    ...
#if defined(ADC_VER_V5_V90)
    if(ADCx==ADC3)
    {
      MODIFY_REG(ADCx->CFGR,
                 ADC3_CFGR_RES
                 | ADC_CFGR_AUTDLY
                 ,
                 ((__LL_ADC12_RESOLUTION_TO_ADC3(ADC_InitStruct->Resolution)  & (ADC_CFGR_RES_1 | ADC_CFGR_RES_0)) << 1UL)
                 | ADC_InitStruct->LowPowerMode
                );
    }
    else
    ...

Running the code, ADC3->CFGR is indeed 0x80000000 both before and after LL_ADC_Init() as the incorrectly calculated resolution bits are masked by MODIFY_REG().

(CubeMX v6.6.1 generating code for STM32H723)

EDIT: The problem with the variable for the while-loop not being volatile seems to remain.

8 REPLIES 8
Imen.D
ST Employee

Hello @Magnus Kristiansen-Modéer​ 

First, let me welcome you to the STM32 Community 🙂 and thank you for having reported this issue.

I will escalate this issue along to our development team for fix.

Thanks

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Imen.D
ST Employee

Hi @Magnus Kristiansen-Modéer​ ,

Can you please confirm that you are using latest release of STM32CubH7 MCU package?

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

I wasn't then but have now upgraded to STM32Cube_FW_H7_V1.11.0 and CubeMX 6.7.0 and it's still the same.

Hi @Magnus Kristiansen-Modéer​,

I recommend you update the latest release of STM32CubeH7 and STM32CubeMx.

This issue is fixed since STM32CubeMX-6.4.0 and CubeH7 version V1.9.1

As mentioned in the release note of STM32CubeH7:

HAL/LL ADC:

  • Update LL ADC driver to correctly configure the ADC3 resolution on some devices.

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

But I just told you that it still happens with CubeMX 6.7.0 and CubeH7 1.11.0 (and I said in my inital post that I used CubeMX 6.6.1 then).

Sorry, I haven't seen your last comment.

I will check this internally and come back to you soon.

Thanks for your understanding.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

> I haven't seen your last comment.

But you pressed "Reply" on that specific comment...

mkm_ctv
Associate II

Any updates on this?