STM32 changes 12M crystal to 8M crystal oscillator, Keil and program settings

Publisher:wmghyuLatest update time:2018-08-21 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

If you want to change the external 12M crystal to an 8M crystal, and still use a 72MHZ clock, you only need to change three places:

First: stm32f10x.h and system_gd32f10x.c files can be found by the following figure

 

STM32 changes 12M crystal to 8M crystal


1. In stm32f10x.h, change #define HSE_VALUE ((uint32_t)12000000) to #define HSE_VALUE ((uint32_t)8000000)

In stm32f10x.h, the changes are as follows

STM32 changes 12M crystal to 8M crystal

2. In system_gd32f1x0.c, the macro of 72M is used, which is changed to the following:
//#define SYSCLK_FREQ_HSE    HSE_VALUE 
//#define SYSCLK_FREQ_24MHz  24000000  
//#define SYSCLK_FREQ_36MHz  36000000 
//#define SYSCLK_FREQ_48MHz  48000000 
//#define SYSCLK_FREQ_56MHz  56000000 
#define SYSCLK_FREQ_72MHz  72000000

 

After changing the stm32f10x.h file, the data is as follows

STM32 changes 12M crystal to 8M crystal


3. If you are debugging and downloading in Keil, modify the project options as follows: change the Xtal (MHz) label from 12.0 to 8.0.

                                                 STM32 changes 12M crystal to 8M crystal

 Finally, be sure to note that when configuring the clock, do not forget to change the frequency multiplication factor. In the clock initialization function void RCC_Configuration(void), change RCC_PLLMul_6 to RCC_PLLMul_9, that is:

         
    RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);


Of course, if you change 8M to 12M or other crystal oscillators, the method is similar


Keywords:STM32 Reference address:STM32 changes 12M crystal to 8M crystal oscillator, Keil and program settings

Previous article:Using 12M external crystal oscillator with stm32 under IAR
Next article:How to modify the code when STM32 uses a non-8M crystal

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号