历史上的今天
今天是:2024年10月08日(星期二)
2021年10月08日 | STM8S CPU主时钟
2021-10-08 来源:eefocus
STM8S上电后的时钟来源:

/* Public functions ----------------------------------------------------------*/
/**
* @addtogroup CLK_Public_Functions
* @{
*/
/**
* @brief Deinitializes the CLK peripheral registers to their default reset
* values.
* @param None
* @retval None
* @par Warning:
* Resetting the CCOR register: n
* When the CCOEN bit is set, the reset of the CCOR register require
* two consecutive write instructions in order to reset first the CCOEN bit
* and the second one is to reset the CCOSEL bits.
*/
void CLK_DeInit(void)
{
CLK->ICKR = CLK_ICKR_RESET_VALUE;
CLK->ECKR = CLK_ECKR_RESET_VALUE;
CLK->SWR = CLK_SWR_RESET_VALUE; // 0xE1
CLK->SWCR = CLK_SWCR_RESET_VALUE;
CLK->CKDIVR = CLK_CKDIVR_RESET_VALUE;
CLK->PCKENR1 = CLK_PCKENR1_RESET_VALUE;
CLK->PCKENR2 = CLK_PCKENR2_RESET_VALUE;
CLK->CSSR = CLK_CSSR_RESET_VALUE;
CLK->CCOR = CLK_CCOR_RESET_VALUE;
while ((CLK->CCOR & CLK_CCOR_CCOEN)!= 0)
{}
CLK->CCOR = CLK_CCOR_RESET_VALUE;
CLK->HSITRIMR = CLK_HSITRIMR_RESET_VALUE;
CLK->SWIMCCR = CLK_SWIMCCR_RESET_VALUE;
}
CPU上电后是内站HSI时钟,16MHz : 16 MHz high-speed internal RC oscillator (HSI)
得到其它的时钟,可以通过时钟分频寄存器(CLK_CKDIVR)对时钟进行分频:

CPU 时钟分频器
CPU时钟(f CPU )由主时钟(f MASTER )分频而来,分频因子由时钟分频寄存器(CLK_CKDIVR)中的位
CPUDIV[2:0]决定。共7个分频因子可供选择(1至128中,2的幂)。f CPU 为CPU和窗口看门狗提供时钟。
那么CPU主时钟来源:
4.5 Clock controller
The clock controller distributes the system clock (fMASTER) coming from different
oscillators to the core and the peripherals. It also manages clock gating for low power
modes and ensures clock robustness.
Features
Clock prescaler: to get the best compromise between speed and current consumption
the clock frequency to the CPU and peripherals can be adjusted by a programmable
prescaler.
Safe clock switching: clock sources can be changed safely on the fly in run mode
through a configuration register. The clock signal is not switched until the new clock
source is ready. The design guarantees glitch-free switching.
Clock management: to reduce power consumption, the clock controller can stop the
clock to the core, individual peripherals or memory.
Master clock sources: four different clock sources can be used to drive the master
clock:
– 1-16 MHz high-speed external crystal (HSE)
– Up to 16 MHz high-speed user-external clock (HSE user-ext)
– 16 MHz high-speed internal RC oscillator (HSI)
– 128 kHz low-speed internal RC (LSI)
Startup clock: After reset, the microcontroller restarts by default with an internal 2 MHz
clock (HSI/8). The prescaler ratio and clock source can be changed by the application
program as soon as the code execution starts.
Clock security system (CSS): This feature can be enabled by software. If an HSE
clock failure occurs, the internal RC (16 MHz/8) is automatically selected by the CSS
and an interrupt can optionally be generated.
Configurable main clock output (CCO): This outputs an external clock for use by the
application.
下一篇:STM8 定时器Time1使用
史海拾趣
|
小弟单片机新手,刚买个c8051f020评估板,想用它做一个数据采集系统,想同时采集三路电压信号。电压大小3-9V吧,想知道该如何设计这个采集系统,外围电路都应该有什么。。。。请各位大侠给点指点,或者能给个实例啥的让小弟研究一下;P… 查看全部问答> |
|
1. 从事了ARM2410的硬件调试(调试软件自己编写)。 2. 从事过简单wince驱动编写。 3. 从事过以evc为开发环境的应用程序的编写。 4. 从事过各种工业总线的通信。 5. 工作年限2年。 昨天知道整个部门只有我没有奖金(因为上一个项目领导没给我 ...… 查看全部问答> |
|
这是我的电路图。。 下面是我的代码 #include #include #define UINT unsigned int UINT cnt = 0; void main() { TMOD = 0X01; TH0 = (65536 - 50000) / 256; TL0 = (65536 - 50000) % 256; ...… 查看全部问答> |
|
VC6在windows7下兼容问题解决办法 [url=http://hi.baidu.com/setid/blog/item/c18d66df5e67a5186227985d.html/cmtid/142ad11ec0ecba124134178a][/url] … 查看全部问答> |
|
FILE *f; f =fopen(DATAFILE, \"r\"); 复制代码 就是不能执行,请高手帮助解决,分不够开口我现在只能给100… 查看全部问答> |
|
打算做自己的数控系统,采用开放式架构即通用计算机+操作系统+CNC应用软件+运动控制总线通讯卡。 从工厂应用环境角度,对计算机的硬件配置有哪些特殊要求?换个角度说工控机用的CPU及其外围器件和通用PC比在性能上的有哪些区别? 另外在操作系统 ...… 查看全部问答> |
|
1、BSD TCP/IP协议栈 BSD栈历史上是其他商业栈的起点,大多数专业TCP/IP栈(VxWorks内嵌的TCP/IP 栈)是BSD栈派生的。这是 因为BSD栈在BSD许可协议下提供了这些专业栈的雏形,BSD许用证允许BSD栈以修改或未 ...… 查看全部问答> |
|
本章的上一节向读者介绍了Keil MDK的安装流程与在Keil MDK的μVision4集成开发环境下进行stm32工程的建立方法。本节我们就来看看如何使用Keil MDK开发工具进行stm32应用程序的开发。 在此之前有必要向大家介绍几个名词,Keil、MDK、μVision ...… 查看全部问答> |




