2022-02-28 02:56 AM
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.
Thanks for all answers in advance
BR's
Martin
Solved! Go to Solution.
2022-02-28 05:46 AM
Failure found, was a Misstypo in SCM -> wrong µC in project.
Stay Healthy
Martin
2022-02-28 03:44 AM
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
2022-02-28 05:46 AM
Failure found, was a Misstypo in SCM -> wrong µC in project.
Stay Healthy
Martin