William Chang

What happen to the SYSCLK before and after SystemInit() in the first time

Blog Post created by William Chang on May 13, 2018

The contents below is appliable in STM32F1xx.

What SystemInit() I mean here?

It is a standard CMSIS Function name located at system_stm32f1xx.c

What SYSCLK means?

SYSCLK stands for System clock. //main peripherals clock source

 

Before SystemInit()

System clock selection is performed on startup, however, the internal RC 8 MHz oscillator is selected as default CPU clock on reset.

Then

The values on the BOOT pins are latched on the 4th rising edge of SYSCLK after a reset. It is up to the user to set the BOOT1 and BOOT0 pins after Reset to select the required boot mode.

Then
The CPU fetches the top-of-stack value from address 0x0000 0000, then starts code execution from the boot memory starting from 0x0000 0004.

Then

reset handler

Then

SystemInit()

After SystemInit()

I found what it has done are

1. enable the HSI clock

2. Select HSI as system clock

3. All AHB, APB1, APB2 prescaler set to 1

4. ADC prescaler set to default PCLK2 divided by 2

5. No MCO output

6. HSE oscillator OFF

7. Clock security system Disable

8. PLL OFF

9. external oscillator not bypassed

10. HSI oscillator clock / 2 selected as PLL input clock

11. HSE clock not divided

12. PLL input clock x 2

13. USB prescaler PLL clock is divided by 1.5

Outcomes