cancel
Showing results for 
Search instead for 
Did you mean: 

Does stm32cubemx generate an incorrect SystemClock_Config() when using the RCC LL driver?

FM.1
Associate III

Are the LL drivers for RCC ready for production code (I plan to use the STOP mode using the LL drivers ...)?

There seems an issue with stm32cubemx 6.8.0 generated code for the NUCLEO L476 dev. board in SystemClock_Config() when selecting RCC LL drivers: it blocks in a while loop. The code is as follows:

__STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_VOS(void)
{
  return ((READ_BIT(PWR->SR2, PWR_SR2_VOSF) == (PWR_SR2_VOSF)) ? 1UL : 0UL);
}
 
void SystemClock_Config(void)
{
  LL_FLASH_SetLatency(LL_FLASH_LATENCY_0);
  while(LL_FLASH_GetLatency()!= LL_FLASH_LATENCY_0)
  {
  }
  LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1);
  while (LL_PWR_IsActiveFlag_VOS() == 0)
  {
  }
...

LL_PWR_IsActiveFlag_VOS() returns 1 while the regulator is adjusting itself according to the data specification:

Bit 10 VOSF: Voltage scaling flag

A delay is required for the internal regulator to be ready after the voltage scaling has been

changed. VOSF indicates that the regulator reached the voltage level defined with VOS bits

of the PWR_CR1 register.

0: The regulator is ready in the selected voltage range

1: The regulator output voltage is changing to the required voltage level

Seems in my case regulator is adjusted quickly and so zero is returned, which ends up in a endless loop. A similar check, when using the HAL RCC driver, does the opposite:

...
      wait_loop_index = ((PWR_FLAG_SETTING_DELAY_US * SystemCoreClock) / 1000000U) + 1U;
      while ((HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_VOSF)) && (wait_loop_index != 0U))
      {
        wait_loop_index--;
      }
      if (HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_VOSF))
      {
        return HAL_TIMEOUT;
      }
...

3 REPLIES 3
Diane POMABIA
ST Employee

Hi @FM.1​ 

Can you give me your Firmware Package version in CubeMx ? because after generate the code with stm32cubemx 6.8.0 for nucleo board , i have :

     /* Wait until VOSF is cleared */
      wait_loop_index = ((PWR_FLAG_SETTING_DELAY_US * SystemCoreClock) / 1000000U) + 1;
      while ((HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_VOSF)) && (wait_loop_index != 0U))
      {
        wait_loop_index--;
      }
      if (HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_VOSF))
      {
        return HAL_TIMEOUT;
      }
    }

That will not be block in loop.

My firmware package Name and version is STM32Cube FW_L4 V1.17.2

Regards

Diane

Thank you for looking into this @Diane POMABIA​ ! The code you use is based on the HAL driver and works correctly (what I also mention in my post).

I have meanwhile found I'm not the only one who ran into this. And that ST is aware and created an internal issue with fix (with hopefully soon a new release). See here:

https://github.com/STMicroelectronics/STM32CubeL0/issues/31 and here:

https://github.com/STMicroelectronics/STM32CubeF7/issues/85

@FM.1​ 

Thanks you for your feedback.Theses issues you reported have been logged into an internal bug tracker, it will be managed by the development team.

Regards

Diane