cancel
Showing results for 
Search instead for 
Did you mean: 

Problems setting up clocks, STM32F401RE

bjornpaulstrom
Associate III
Posted on October 04, 2016 at 09:47

Hello I am using a nucleoboard and am trying to set up all the clocks using this:

RCC_ClocksTypeDef RCC_Clocks;

RCC_HSICmd(ENABLE);

RCC_HCLKConfig(RCC_SYSCLK_Div1);

RCC_PCLK2Config(RCC_HCLK_Div1);

RCC_PCLK1Config(RCC_HCLK_Div2);

RCC_PLLConfig(RCC_PLLSource_HSI, 16, 336, 4, 2);

RCC_PLLCmd(ENABLE);

while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);

RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

while (RCC_GetSYSCLKSource() != 0x08);

RCC_GetClocksFreq(&RCC_Clocks);

uint32_t clock = RCC_Clocks.SYSCLK_Frequency;

However clock is not the 84MHz I expected, it is 131250000. What am I doing wrong?

#stm32f4
3 REPLIES 3
slimen
Senior
Posted on October 04, 2016 at 11:17

Hello,

Review RCC example under 

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32-standard-peripheral-libraries/stsw-stm32065.html

 STM32F4 DSP and standard peripherals library, this help you on RCC configuration:

 STM32F4xx_DSP_StdPeriph_Lib_V1.7.1\Project\STM32F4xx_StdPeriph_Examples\RCC\RCC_Example

Regards

Posted on October 04, 2016 at 13:12

And what is the real system clock (eg. as output and measured at a MCO pin)?

131250000/84MHz = 25/16

If you are sure the system clock is indeed 84MHz, your software might think you are running from a 25MHz clock. Check the relevant RCC registers (concentrating on RCC_PLLCFGR) after setting them; if you find them to be as expected then it's either library, or a library-usage issue.

JW

michaelc.barton9
Associate II
Posted on October 04, 2016 at 14:01

Majerle Tilen did a good informative page regarding F4 clockspeeds

http://stm32f4-discovery.net/2015/01/properly-set-clock-speed-stm32f4xx-devices/

HTH