Skip to main content
MHantke_001
Associate II
February 28, 2022
Solved

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

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

This topic has been closed for replies.
MHantke_001
MHantke_001Best answer
Associate II
February 28, 2022

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

Stay Healthy

Martin

2 replies

MHantke_001
Associate II
February 28, 2022

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
MHantke_001AuthorBest answer
Associate II
February 28, 2022

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

Stay Healthy

Martin