STM8S如何跑24M的HSE晶振

就这么几步,

第一步: 检查STM8s.h头文件配置

/**
  * @brief  In the following line adjust the value of External High Speed oscillator (HSE)
   used in your application

   Tip: To avoid modifying this file each time you need to use different HSE, you
        can define the HSE value in your toolchain compiler preprocessor.
  */
#if !defined  HSE_Value
 #if defined (STM8S208) || defined (STM8S207) || defined (STM8S007) || defined (STM8AF52Ax) || \
     defined (STM8AF62Ax) || defined (STM8AF622x)
  #define HSE_VALUE ((uint32_t)24000000) /* Value of the External oscillator in Hz*/
 #else
  #define HSE_VALUE ((uint32_t)16000000) /* Value of the External oscillator in Hz*/
 #endif /* STM8S208 || STM8S207 || STM8S007 || STM8AF62Ax || STM8AF52Ax || STM8AF622x */
#endif /* HSE_Value */

 

第二步:代码配置外部时钟

    CLK_DeInit();
    CLK_HSICmd(DISABLE);    //禁止内部高速晶振
    CLK_ClockSwitchCmd(ENABLE);     //使能时钟切换
    CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSE, DISABLE, CLK_CURRENTCLOCKSTATE_DISABLE);    //时钟切换(自动切换模式,切换到外部时钟,禁止切换中断,当前钟状态为)
    CLK_SYSCLKConfig(CLK_PRESCALER_CPUDIV1);      //配置CPU的分频器

    CLK_ClockSecuritySystemEnable();
    CLK_HSECmd(ENABLE);

 

第三步:非常重要!!检查Options配置位打开WaitState,等待时钟启动稳定。

这一步在生产烧录时不能忘了,多少有点蛋疼。。。

 

 

最后,16M到24M超频性能并不是2->3的提升,,,

详见这位大牛的分析:

http://bbs.elecfans.com/jishu_805711_1_1.html

 

你可能感兴趣的:(ST,8bit,STM8)