Systick is slow, usually with a 32k external crystal, used for timing. Sysclk is the main clock, which is the highest 72M for the core and most peripherals. HCLK is the high-speed peripheral clock, which is for external devices, such as memory, flash
SYSCLK system clock, maximum 72MHz
HCLK: AHB bus clock, obtained by dividing the system clock SYSCLK. Generally, it is not divided, which is equal to the system clock passing through the bus bridge AHB--APB. By setting the division, the PCLK1 and PCLK2 clocks can be obtained from HCLK. However, the maximum of PCLK2 clock can reach 72MHz, while the maximum of PCLK1 is 36MHz. PCLK2 corresponds to APB2 peripherals. PCLK1 corresponds to APB1 peripherals.
AHB (HCLK) clock = SYSCLK = 72MHz
APB2 (PCLK2) clock = AHB clock = 36MHz
APB1 (PCLK1) clock = AHB 1/2 clock = 72MHzADC clock = PCLK2 1/4 = 9MHzPLL clock = HSE*9 = 72MHz
The clock is the pulse of the STM32 microcontroller and the driving source of the microcontroller. The corresponding clock must be turned on when using any peripheral. The advantage of this is that if a peripheral is not used, its clock can be turned off, thereby reducing the power consumption of the system, achieving energy saving and low power consumption.
The clock of the STM32 microcontroller can be provided by the following three clock sources:
1. HSI: High-speed internal clock signal. The clock (8M frequency) in the STM32 microcontroller has poor accuracy.
2. HSE: High-speed external clock signal with high precision (1) HSE external crystal/ceramic resonator (crystal oscillator) (2) HSE user external clock
3. LSE: Low-speed external crystal 32.768kHz mainly provides an accurate clock source and is generally used as an RTC clock
The stm32 microcontroller divides or multiplies the clock signal (such as HSE) by PLL to obtain the system clock, which is then divided to generate the clock used by the peripherals.
Understand the clock of the stm32 microcontroller. Here is how to use it. I will give an example of using the HSE clock.
Setting the clock process:
1. Reset the RCC register to the default value RCC_DeInit
2. Turn on the external high-speed clock crystal HSE RCC_HSEConfig (RCC_HSE_ON);
3. Wait for the external high-speed clock crystal to work HSEStartUpStatus = RCC_WaitForHSEStartUp();
4. Set AHB clock RCC_HCLKConfig;
5. Set high-speed AHB clock RCC_PCLK2Config;
6. Set the low speed AHB clock RCC_PCLK1Config
7. Set PLL RCC_PLLConfig
8. Enable PLL RCC_PLLCmd(ENABLE);
9. Wait for PLL to work while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
10. Set the system clock RCC_SYSCLKConfig
11. Determine whether PLL is the system clock while (RCC_GetSYSCLKSource() != 0x08)
12. Open the peripheral clock RCC_APB2PeriphClockCmd()/RCC_APB1PeriphClockCmd() to be used
In STM32, there are five clock sources: HSI, HSE, LSI, LSE, and PLL.
①. HSI is a high-speed internal clock, RC oscillator, with a frequency of 8MHz.
②. HSE is a high-speed external clock that can be connected to a quartz/ceramic resonator or an external clock source with a frequency range of 4MHz~16MHz.
③. LSI is a low-speed internal clock, RC oscillator, with a frequency of 40kHz.
④. LSE is a low-speed external clock connected to a quartz crystal with a frequency of 32.768kHz.
⑤、PLL is a phase-locked loop frequency multiplication output, and its clock input source can be selected as HSI/2, HSE or HSE/2. The frequency multiplication can be selected from 2 to 16 times, but
The maximum output frequency shall not exceed 72MHz.
The system clock SYSCLK is the clock source for most components in STM32. The system clock can be selected as PLL output, HSI or HSE. The maximum frequency of the system clock is 72MHz. It is divided by the AHB divider and sent to each module. The AHB divider can be divided by 1, 2, 4, 8, 16, 64, 128, 256, 512. The clock output by the AHB divider is sent to 5 major modules:
①. HCLK clock sent to AHB bus, core, memory and DMA.
②. The system timer clock is sent to Cortex after being divided by 8.
③. Send the idle running clock FCLK directly to Cortex.
④、Send to APB1 divider. APB1 divider can select 1, 2, 4, 8, 16 frequency division, one of its outputs is used by APB1 peripherals (PCLK1, maximum frequency 36MHz), and the other is sent to timer (Timer) 2, 3, 4 frequency multiplier. The frequency multiplier can select 1 or 2 frequency multiplication, and the clock output is used by timer 2, 3, 4.
⑤. Send to APB2 divider. APB2 divider can select 1, 2, 4, 8, 16 frequency division, one of its outputs is used by APB2 peripherals (PCLK2, maximum frequency 72MHz), and the other is sent to Timer 1 multiplier. The multiplier can select 1 or 2 times, and the clock output is used by Timer 1. In addition, APB2 divider has one output for ADC divider, which is sent to ADC module after frequency division. ADC divider can select 2, 4, 6, 8 frequency division.
Among the above clock outputs, many have enable control, such as AHB bus clock, core clock, various APB1 peripherals, APB2 peripherals, etc. When you need to use a module, remember to enable the corresponding clock first.
Previous article:STM32 clock enable and application summary
Next article:stm32 independent watchdog clock configuration
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- Asynchronous Timing Design in ASIC.pdf
- [Repost] "Very Silly" Circuit Problem
- E840-DTU device connection to Alibaba Cloud test
- Interface corresponding to SNVS_TAMPER3 signal
- Looking for a good and available domestic accelerometer
- nRF52832-QFAA Hardware Reference Design
- 【RPi PICO】Snapshot of the RP2040 chip
- Why does TIM1_CH3N not output PWM after configuring PWM in STM32F103C8T6?
- Can you recommend a chip that can boost 3.3V to 5V?
- How to quickly gain points?