I have a STM32F427 MCU with a 8MHz HSE crystal. I am setting up the clock as follows:
#include <stm32f4xx.h>
#include <stm32f4xx_rcc.h>
void initClocks(void);
void initClocks(void) {
/*
HSE: 8 MHz
PLL: HSE / 8 * 192 => 192 MHz
SysCLK: PLL / 2 => 96 MHz
PrphCLK: PLL / 4 => 48 MHz
*/
RCC_PLLConfig(RCC_PLLSource_HSE, 8, 192, 2, 4);
RCC_PLLCmd(ENABLE);
// Wait
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) continue;
// Use PLL
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
while (RCC_GetSYSCLKSource() != 0x08) continue;
RCC_HCLKConfig(RCC_SYSCLK_Div1);
RCC_PCLK2Config(RCC_SYSCLK_Div1);
RCC_PCLK1Config(RCC_SYSCLK_Div1);
}
int main(void) {
RCC_ClocksTypeDef ClksFreq;
initClocks();
SystemCoreClockUpdate();
RCC_GetClocksFreq(&ClksFreq);
while(1) {}
}
HSE_VALUE is defined to 8000000
My debugger shows that SYSCLK
in ClksFreq
is 57.6MHz, though I would expect it to be 96Mhz.
What am I missing?
while(x != y);
is sufficient for a loop without thecontinue
statement. I tend to reserve a second line and indent the;
. \$\endgroup\$continue
is not necessary, but I feel adding it makes it a bit easier to read when there is a "verb". \$\endgroup\$