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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章