STM8 series MCU clock setting

Publisher:玉立风华Latest update time:2020-09-11 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

To reduce power consumption, the clock management module can stop the clocks to the CPU, memory, and other independent peripherals.


There are four clock sources:

External high speed crystal oscillator (HSE 1-16MHZ)

Internal high speed RC oscillator (HSI 16MHZ)

External low speed crystal oscillator (LSE 32.768)

Internal low speed RC oscillator (LSI 38KHZ)

The default startup clock is internal 2MHZ (HIS/8)


The CSS clock safety system can be enabled by software. Once enabled, the system can automatically switch to HSI when the HSE stops oscillating.


CCO clock output function

1. Select the clock source

void CLK_DeInit(void) Reset all clock registers

void CLK_HSICmd(FunctionalState NewState) Enable or disable the internal high speed oscillator

void CLK_HSEConfig(CLK_HSE_TypeDef CLK_HSE) Enable, disable or bypass the external high speed oscillator

Parameters CLK_HSE_OFF CLK_HSE_ON CLK_HSE_Bypass

void CLK_ClockSecuritySystemEnable(void) CSS clock security system enable

 

2. Configure CPU clock

void CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_TypeDef CLK_SYSCLKSource)

Parameters: CPU clock source CLK_SYSCLKSource_HSI CLK_SYSCLKSource_HSE

                    CLK_SYSCLKSource_LSI CLK_SYSCLKSource_LSE

void CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_TypeDef CLK_SYSCLKDiv)

Parameters: CPU clock division coefficient CLK_SYSCLKDiv_1 CLK_SYSCLKDiv_2 CLK_SYSCLKDiv_4

      CLK_SYSCLKDiv_8 CLK_SYSCLKDiv_16 CLK_SYSCLKDiv_64 CLK_SYSCLKDiv_128


3. Enable the peripheral clocks used

void CLK_PeripheralClockConfig(CLK_Peripheral_TypeDef CLK_Peripheral, FunctionalState NewState)

The first parameter is the peripheral name, such as CLK_Peripheral_TIM1. The second parameter is enable/disable.


4. Configure other peripherals that use non-CPU clocks (RTC/LCD, BEEP, etc.)


Reference address:STM8 series MCU clock setting

Previous article:IIC protocol based on stm8 --- DS3231 clock module reading
Next article:STM8 series MCU timer operation

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号