cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L051R8Tx Clockswitch gives Timeout Used FW_Package: 1.12.1 Debugger ST-LINK V2 IDE: STM32CubeIDE

MHantke_001
Associate II

Hello Community,

i have the strange behavior that the Clockswitch to HSE does not work in STM32L051.

    __HAL_RCC_SYSCLK_CONFIG(RCC_ClkInitStruct->SYSCLKSource);
 
    /* Get Start Tick */
    tickstart = HAL_GetTick();
 
    if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_HSE)
    {
      while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_SYSCLKSOURCE_STATUS_HSE)
      {
        if((HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE)
        {
          return HAL_TIMEOUT;
        }
      }
    }

I always hit the Timeout value due to RCC->CFGR->SW will never be set to "8".

"8" means External Highspeed Oscillator.

A check of the SFRs shows me that RCC->CFGR->SW has a width of 2Bits but i need at least the 3 Bits for value "8".

RCC->CR-> HSERDY and HSEON shows "1" as expected and is measure 8 MHz Oscillator Frequency switched On. 0693W00000KamC7QAJ.png 

Thanks for all answers in advance

BR's

Martin

1 ACCEPTED SOLUTION

Accepted Solutions
MHantke_001
Associate II

Failure found, was a Misstypo in SCM -> wrong µC in project.

Stay Healthy

Martin

View solution in original post

2 REPLIES 2
MHantke_001
Associate II

Additional Information: Understood the bitmasking for Value "8" and

Code Line

__HAL_RCC_GET_SYSCLK_SOURCE() ((uint32_t)(READ_BIT(RCC->CFGR,RCC_CFGR_SWS)))

We check HW and come back again

MHantke_001
Associate II

Failure found, was a Misstypo in SCM -> wrong µC in project.

Stay Healthy

Martin