STM32F407 modification program to modify the external 25M crystal oscillator to 8M

Foreword: Since the external crystal oscillator used by the STM32F407 board designed by myself is 8M, the routine of using the Wildfire F407 (external crystal oscillator is 25M) also needs to modify the external crystal oscillator to use it.

The modification in the program only needs to modify two places.

But according to what the Internet said, I modified HSE_VALUE in stm32f4xx.h and modified PLL_M in system_stm32f4xx.c, but I did not find the relevant definition, and finally found the relevant definition elsewhere and modified it.

(1) Modify HSE_VALUE
to define the macro

#define  HSE_VALUE 	((uint32_t)25000000)

changed to

#define  HSE_VALUE 	((uint32_t)8000000)

The modified file is on line 99 of stm32f4xx_hal_conf.h , as shown below:
Insert picture description here

(2), modify PLL_M

Will 25

RCC_OscInitStruct.PLL.PLLM = 25;

Amended to 8

RCC_OscInitStruct.PLL.PLLM = 8;

The modification of this is in the main.c file SystemClock_Config(void), as shown below;
Insert picture description here

Modification of the external crystal oscillator of the Wildfire Standard Library, 25M changed to 8M

Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/qq1291917670/article/details/111356293