cancel
Showing results for 
Search instead for 
Did you mean: 

HSE startup timeout on STM32F103RET7

DMath
Associate

I'm new to the STM32 so I apologize in advance for the trivial question.

In the following code from SetSysClockTo72() system_stm32f10x.c, the value for HSE_STARTUP_TIMEOUT is 0x0500.  What max delay (msec) does this equate to?

 /* Wait till HSE is ready and if Time out is reached exit */

do

 {

   HSEStatus = RCC->CR & RCC_CR_HSERDY;

   StartUpCounter++; 

 } while((HSEStatus == 0) && (StartUpCounter != HSE_STARTUP_TIMEOUT));

I am running into an issue where we are seeing sporadic delay in the bootup sequence at cold temperatures and we're in the process of looking under every rock.

Thanks for the help.

1 REPLY 1

> What max delay (msec) does this equate to?

That depends on the clock you are running currently at, FLASH latency (if it's running out of FLASH), and the optimization choices of the compiler. You'll be better off measuring it (the simplest way is to toggle a GPIO pin at the beginning and end of the routine while preventing the oscillator to start up (remove the crystal or short the oscillator's input pin to ground) and look at that pin using a LA). Or, even better, write your own routine with a known good source of timing (e.g. running a timer).

> I am running into an issue where we are seeing sporadic delay in the bootup sequence at cold

> temperatures and we're in the process of looking under every rock.

This might be a good place to look at, oscillator is a low-power circuit and crystal is an electromechanical device which may change its behaviour substantially with temperature and slightly changing properties of the surrounding electronic circuitry. You may want to output the HSE to a MCO pin and look there for the startup duration; direct probing of the crystal is not recommended as it certainly changes its behaviour especially at startup.

If you use a climatic chamber it may also act as a Faraday cage and that also may be the cause for slower oscillator startup, paradoxically more so if the oscillator is well designed, as crystal oscillators start up by picking RF noise from the environment...

JW