2012-05-01 08:29 AM
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);}2012-05-01 09:11 AM
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.2012-05-01 09:34 PM
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.2012-05-02 04:18 AM
Great, thanks for the quick and helpful responses!