【STM32】: RCC clock system

foreword

Time cannot be met, and Tao cannot be done in vain.


1. Clock tree block diagram

  • HSI oscillator clock
  • HSE Oscillator Clock
  • Main PLL (PLL) clock

The above three clock sources can be used to drive the system clock (SYSCLK);

There are also two secondary clock sources:

  • 32 kHz low-speed internal RC (LSI RC) used to drive a stand-alone watchdog and optionally to the RTC for automatic wake-up in stop/standby mode
  • 32.768 kHz low-speed external crystal (LSE crystal) to drive the RTC clock (RTCCLK)
    insert image description here

  • AHB frequency, high-speed APB (APB2) and low-speed APB (APB1) are configurable through multiple prescalers. The maximum frequency of the AHB domain is 168 MHz. The maximum allowed frequency in the high-speed APB2 domain is 84 MHz. The maximum allowed frequency in the low-speed APB1 domain is 42 MHz.
  • The RCC feeds the AHB clock (HCLK) divided by 8 to the Cortex system timer (SysTick). SysTick can use this clock as clock source or HCLK as clock source, which can be configured in SysTick Control and Status Register.

insert image description here
insert image description here
insert image description here
insert image description here

insert image description here

insert image description here

insert image description here
insert image description here
insert image description here

insert image description here
insert image description here


SystemInit clock system initialization function

  • The execution sequence of the SystemInit function is before the main function, as can be seen in the startup file:
    insert image description here
    insert image description here
    insert image description here

Systick timer (tick timer)

1. Basic knowledge

  • Systick timer is a simple timer, both for CM3 and CM4 core chips.
  • Systick timers are often used for delay, or the heartbeat clock of real-time systems, which can save MCU resources and do not waste a timer. For example, in UCOS, time-division multiplexing requires a minimum timestamp, generally in stm32 + UCOS systems , both use the Systick timer as the UCOS heartbeat clock.
  • The Systick timer is the system tick timer, a 24-bit countdown timer, when it counts to 0, it will automatically reload the timing initial value from the RELOAD register, as long as it is not set in the enable bit in the Systick control and status register Clear and it never stops, works even in sleep mode
  • Systick timer is bundled in NVIC to generate SYSTICK exception (exception number: 15)
  • The priority of Systick interrupt can also be set

2. Library functions

3. Related registers

  • CTRL: Systick control and status register LOAD
  • SysTick: Auto-reload divisor register
  • VAL: Systick current value register CALIB
  • Systick: Calibration value register

insert image description here
insert image description here
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/WandZ123/article/details/127177219