cancel
Showing results for 
Search instead for 
Did you mean: 

Startup Clock HSI

markgilson9
Associate II
Posted on May 01, 2012 at 17:29

I'm simply looking to have the STM32F4 startup using the HSI clock (at the default 16MHz).  How best can this be accomplished (if it's not already default).  What clock does the STM32F4 natively startup using?  I was thinking this would work:

static void SetSysClock(void)

{

/* RCC system reset(for debug purpose) */

RCC_DeInit();

// Enable HSI Clock and wait until it's ready

RCC_HSICmd(ENABLE);

while(RCC_GetFlagStatus(RCC_FLAG_HSIRDY) == RESET);

}
3 REPLIES 3
Posted on May 01, 2012 at 18:11

STM32's always start running from the HSI.

Your code might be more effective if it first checked the HSI was enabled and ready.

The most effective clock changing strategy is to always look at which clocks are currently being used, rather than assuming initial conditions. This tends to avoid unnecessary grinding of gears, or slipping into neutral.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
fastmapper2
Associate II
Posted on May 02, 2012 at 06:34

1. On reset, the STM32F4 uses the 16MHz HSI oscillator as the CPU clock (see the datasheet).

2. The RCC_DeInit() function selects the HSI oscillator as the CPU clock, but does not wait for the HSI oscillator to be ready before doing so.  As a result, this function should be used either when the HSI oscillator is already ready or when the consequences of selecting the HSI oscillator before it is stable are understood.

3. The RCC_HSICmd() function only enables the HSI oscillator so it can start running, it does not wait for the HSI oscillator to be ready nor does it select the HSI oscillator as the CPU clock.

markgilson9
Associate II
Posted on May 02, 2012 at 13:18

Great, thanks for the quick and helpful responses!