zoukankan      html  css  js  c++  java
  • STM8S——Clock control(CLK)

    1、主时钟源

      有四种时钟源可以用做主时钟:

    (1)1-24MHz高速外部晶体振荡器(HSE)

    (2)最大24MHz高速外部时钟信号(HSE user-ext)

    (3)16MHz高速内部RC振荡器(HSI)

    (4)128KHz低速内部RC(LSI)

      各个时钟源可以单独打开或关闭,从而优化功耗。我们采用HSI。为了使系统快速启动,复位后时钟控制器会自动使用HSI的8分频(HSI/8)作为主时钟;原因是HSI的稳定时间短,而8分频可保证系统在较差的VDD条件下安全启动。

    2、时钟输出功能(CCO)

      可以配置时钟输出功能使用户可以在外部管脚CCO上输出指定的时钟,可选CCO时钟的信号有6种:fHSE、fHSI、fHSIDIV、fLSI、fMASTER、fCPU(可选分频值)。

      设置步骤:首先应该选择设置输出模式;然后需要指定I/O引脚,我们默认的引脚为PE0,所以只需要将两者绑定起来就可以了;最后打开时钟输出使能。

    3、实现代码

     1 /* Includes ------------------------------------------------------------------*/
     2 #include "stm8s.h"
     3 
     4 /* Private function prototypes -----------------------------------------------*/
     5 static void CLK_Config(void);
     6 
     7 /**
     8   * @brief Example  main entry point.
     9   * @param  None
    10   * @retval None
    11   */
    12 void main(void)
    13 {
    14   
    15   // Clock configuration
    16   CLK_Config();
    17   
    18   enableInterrupts();
    19   
    20   // configures the Switch from one clock to another
    21   CLK_ClockSwitchConfig(CLK_SWITCHMODE_AUTO, CLK_SOURCE_HSI, DISABLE, CLK_CURRENTCLOCKSTATE_DISABLE);
    22   
    23   // Connect LSI to COO pin , CLK_CCO--PE0
    24   GPIO_Init(GPIOE, GPIO_PIN_0, GPIO_MODE_OUT_PP_LOW_FAST);
    25   
    26   // Enables the Configurable Clock Output (CCO)
    27   CLK_CCOCmd(ENABLE);  
    28   
    29   /* --- to see if 8mhz is output at CCo pin --- */
    30   
    31   /* ------------------------------------------- */
    32 }
    33 
    34 /**
    35   * @brief  Configure system clock to run at 16Mhz and output the system clock on
    36   *         CCO pin
    37   * @param  None
    38   * @retval None
    39   */
    40 static void CLK_Config(void)
    41 {
    42   CLK_DeInit();
    43   
    44   /* Clock divider to HSI/1 */
    45   CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);
    46   
    47   /* Output Fcpu on CLK_CCO pin */
    48   CLK_CCOConfig(CLK_OUTPUT_MASTER);
    49 }
    CLK
  • 相关阅读:
    appium连接真机时,报错:error: device unauthorized.
    python使用163邮箱发送测试报告遇到smtplib.SMTPAuthenticationError: (550, b'User has no permission')问题
    logging日志重复打印问题
    python实现text/html的get请求
    python实现Post请求四种请求体
    selenium异常类
    unittest所有断言方法
    windows下Jenkins+webdriver无法启动浏览器
    python3+selenium3之 解决:'chromedriver' executable needs to be in PATH问题
    python学习(6)--logging打印日志
  • 原文地址:https://www.cnblogs.com/Christal-R/p/7145176.html
Copyright © 2011-2022 走看看