STM32F103 clock configuration source code learning record

tags: STM32F103  clock

After reading this recordAtomic Battleship EditionThe understanding of the clock configuration video is only used as a memo.

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.

       

        

Intelligent Recommendation

STM32F103 uses internal rc oscillator as clock source

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...

STM32CubeMX configures STM32F103 external clock source

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...

STM32 clock configuration and SysTick configuration_based on STM32F103

【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...

Stm32f103 series use internal clock configuration tutorial

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...

STM32F103 clock

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...

More Recommendation

Record the learning experience of stm32F103 ADC

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)

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...

STM32F103 MCU uses internal RC oscillator as clock source

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...

[SCM Notes] About CotexM3 and STM32F103 series clock understanding and configuration

  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...

RH850 clock source and configuration

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...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top