The clock configuration source code is in the file system_stm32f10x.c. The program first selects the system clock frequency SYSCLK you want by judging the type of f10 chip used. The chip system frequency I use is up to 72Mhz, and the chip capacity is a large-capacity type, so the choice after pre-compilation isSYSCLK_FREQ_72MHz 72000000。
The following code is useless in the clock configuration, but can be passed in the future programSystemCoreClockTo read the frequency of the system clock.
The following code uses macro definition to select the function to configure the system clock. The above function definesSYSCLK_FREQ_72MHz, so the program is executedvoid SetSysClockTo72 (void). Jump to this function
The following function is not important, just skip it
The three lines of code first say that the AHB bus clock is equal to the system clock, and then the APB2 clock is equal to the HCLK divide by one, and the APB1 clock is equal to the HCLK divide by two. The result isHCLK=72MHz,PCLK2=72MHz,PCLK1=36MHz.。It just happens to be the highest frequency allowed on the respective bus.
Look at the picture below and skip the code above it. The code under else is to set the phase-locked loop through the configuration register. The frequency from the phase-locked loop is 9 times the frequency of the external high-speed clock.
Finally, enable the phase-locked loop PLL. After the PLL is ready, use the PLL as the source of the system clock.
To understand the clock configuration source code, you must first understand the clock system block diagram. The two clock diagrams are similar, but the labels are slightly different.

Written in the front: the title "Use the internal rc oscillator as the clock source" is actually not very accurate, the actual should be "use the internal rc oscillatorAfter PLL multipl...
1. Introduction to hardware configuration The elite STM32F103 development board of punctual atom is used, the model is STM32F103ZET6. The external clock of the HSE of the development board is an 8M cr...
【I. Introduction When programming STM32 front and background programs, the most basic configuration should be the configuration of its clock and system timer. For the standard library, call SysTick_In...
Let's take a look at the program first. The advantage of using the internal clock is that it can save costs, but the multiplier can only reach 64MHZ at most. You need to pay attention when using it Co...
1, Category: Divided system clock, peripheral clock. Firmware library complete configuration of the system clock, peripheral clock determined by the division factor. 2, the configuration of the system...
Record the learning experience of stm32F103 ADC table of Contents Configuring stm32CubeMx Write Keil code The principle of AD is not described here. If you don't understand, you can go to other articl...
Transplantation of ucosII on stm32f103 (with source code) 1. Preparation before transplantation 1.ucosII source code download (click to download) 2. Project template establishment (this template proje...
I usually use an external crystal oscillator as the clock source when I am doing a project. I want to try using the internal RC oscillator as the clock source. I searched the Internet for how to set t...
Now attach the clock configuration function that I implemented myself Here is a blog post that reads pretty well and quoted again:Original blog Under normal circumstances, the clock configurati...
1. Clock source There are 5 kinds of system clock sources: External main crystal oscillator 8M-24M. (main osc) The external secondary crystal oscillator is 32.768KHz. (sub osc) Internal high-speed cry...