STM32F107 external crystal oscillator 25MHz configured to run at 72MHz

Publisher:美人如玉剑如虹Latest update time:2016-10-07 Source: eefocusKeywords:STM32F107 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Startup file selection: STM32F10X_CL

/*******************************************************************************
* Function name: RCC_Configuration
* Function: 25MHZ Set the clock of each part of the system 
* Parameter variable: NONE
* Global variable: NONE
* Calling function:
* Author:  
* Writing time:

* 修改时间: 
* 版    本: V1.0 
* 状    态:调试完成
*******************************************************************************/
void RCC_Configuration(void)
{
RCC_DeInit();
RCC_HSEConfig(RCC_HSE_ON);// Enable HSE 
HSEStartUpStatus = RCC_WaitForHSEStartUp();//Wait till HSE is ready 
if(HSEStartUpStatus==SUCCESS)
{
    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);//Enable Prefetch Buffer    
    FLASH_SetLatency(FLASH_Latency_2); // Flash 2 wait state 
    RCC_HCLKConfig(RCC_SYSCLK_Div1);//HCLK = SYSCLK 
    RCC_PCLK2Config(RCC_HCLK_Div1);//PCLK2 = HCLK  
    RCC_PCLK1Config(RCC_HCLK_Div2);//PCLK1 = HCLK/2
    RCC_ADCCLKConfig(RCC_PCLK2_Div4);//ADCCLK = PCLK2/4  
#ifndef STM32F10X_CL 
    RCC_PLLConfig(RCC_PLLSource_HSE_Div1,RCC_PLLMul_9);//PLLCLK = 8MHz * 9 = 72 MHz
#else
    // Configure PLLs *********************************************************
    //PLL2 configuration: PLL2CLK = (HSE / 5) * 8 = 40 MHz 
    RCC_PREDIV2Config(RCC_PREDIV2_Div5);
    RCC_PLL2Config(RCC_PLL2Mul_8);    
    RCC_PLL2Cmd(ENABLE);
    while(RCC_GetFlagStatus(RCC_FLAG_PLL2RDY)== RESET)
    {}
    RCC_PREDIV1Config(RCC_PREDIV1_Source_PLL2,RCC_PREDIV1_Div5);
    RCC_PLLConfig(RCC_PLLSource_PREDIV1,RCC_PLLMul_9);//PLLCLK = 8MHz * 9 = 72 MHz
    RCC_PLL3Config(RCC_PLL3Mul_11);
    RCC_PLL3Cmd(ENABLE);   
    while(RCC_GetFlagStatus(RCC_FLAG_PLL3RDY)== RESET)
    {}
    RCC_I2S3CLKConfig(RCC_I2S3CLKSource_PLL3_VCO);
    RCC_I2S2CLKConfig(RCC_I2S2CLKSource_PLL3_VCO); 
#endif
   RCC_PLLCmd(ENABLE);// Enable PLL 
    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)// Wait till PLL is ready 
    {
    }
    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);// Select PLL as system clock source 
    while(RCC_GetSYSCLKSource() != 0x08)// Wait till PLL is used as system clock source 
    {
    }
 }
}

Keywords:STM32F107 Reference address:STM32F107 external crystal oscillator 25MHz configured to run at 72MHz

Previous article:STM32 APB1 bus clock configuration problem
Next article:STM32 ADC and DMA multi-channel processing

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号