2025-05-27 5:45 AM - edited 2025-05-27 5:52 AM
Hi everyone,
I'm having an issue with HSE bypass mode on the STM32G0B1RCT6 and hoping someone here has seen something similar.
The HSE randomly won't start in bypass mode. I've tried two different oscillators - the S2D8.000000B20F30T and an OT32258MJBA4SL that I pulled from a working STM32F405RGT6 board where it runs without any problems.
The behavior is inconsistent. Sometimes it starts up normally and then runs solid. Other times it just won't set the HSERDY flag. We've tried both toggling the NRST pin and resetting from code, but neither changes the state - if it's working, it stays working, and if it's not working, it stays not working. Only power cycling the entire board can change the state in either direction, sometimes making a non-working board work or making a working board stop working.
On the scope, the signal from the oscillator is always visually fine.
Any ideas or suggestions for debugging this would be helpful!
2025-05-27 6:44 AM - edited 2025-05-27 6:44 AM
I'm not quite sure the HSERDY flag is to be expected to come up, when using HSE bypass mode.
HSERDY flag is supposed to check whether the *oscillator* has already started up and is running in a stable way; whereas with external oscillator i.e. HSE bypass, the expectation is that the oscillator *does* run unconditionally.
In the past, reports on this matter differed (albeit on varying STM32 families which indeed may behave differently), and I'm not sure there is any definitive guide from ST in this regard. If the 'G0 RM says explicitly otherwise, please correct me.
JW
2025-05-27 6:52 AM
@flawless wrote:I've tried two different oscillators - the S2D8.000000B20F30T and an OT32258MJBA4SL
Please give datasheets for those.
Do they meet the STM32's requirements ?
2025-05-27 7:16 AM
2025-05-27 7:55 AM - edited 2025-05-27 7:58 AM
RM doesn't say anything explicitly regarding HSERDY with HSE in bypass mode, but HAL clock startup code does check HSERDY flag regardless of whether crystal or bypass is used:
__HAL_RCC_HSE_CONFIG(RCC_OscInitStruct->HSEState);
/* Check the HSE State */
if (RCC_OscInitStruct->HSEState != RCC_HSE_OFF)
{
/* Get Start Tick*/
tickstart = HAL_GetTick();
/* Wait till HSE is ready */
while (READ_BIT(RCC->CR, RCC_CR_HSERDY) == 0U)
{
if ((HAL_GetTick() - tickstart) > HSE_TIMEOUT_VALUE)
{
return HAL_TIMEOUT;
}
}
}
And even if we assume that HSERDY isn't necessary, the fact that sometimes HSERDY is set and sometimes it doesn't seems misleading.