0 卖盘信息
BOM询价
您现在的位置: 首页 > 电子资讯 >技术信息 > 基于STM32F10时钟系统MCU的开发及配置

基于STM32F10时钟系统MCU的开发及配置

来源: 电子发烧友
2018-10-22
类别:技术信息
eye 215
文章创建人 拍明

原标题:基于STM32时钟系统的开发及配置


一、背景

最近做个项目,需要使用STM32,还是以前一样的观点,时钟就是MCU心脏,供血即时钟频率输出,想要弄明白一个MCU,时钟是一个非常好的切入点。言归正传,网上已经有太多大神详述过STM32的详细配置方法了,在此就简单介绍下STM32时钟系统,以及如何配置做个简单记录,方便以后的快速开发。

二、正文

废话不多说,上一张STM32F10xx的时钟树图:

基于STM32F10时钟系统的开发及配置.png

由图可知,STM32F10XX有两级时钟

第一级时钟

* 高速内部时钟(HSI)

* 锁相环时钟(PLLCLK)

* 高速外部时钟(HSE)

第二级时钟

* 低速内部时钟(LSI)

* 低速外部时钟(LSE)

又由图可知,

* HSE由外部晶振从“OSC_OUT”,“OSC_IN”两脚输入提供。

* LSE由外部晶振从“OSC32_OUT”,“OSC32_IN”两脚输入提供。

* HSI由8MHZ高速内部RC震荡电路提供。

* LSI由40kHZ低速内部RC震荡电路提供。

STM32F10XX还可通过MCO脚向外提供时钟输出。时钟来源有PLLCLK/HSI/HSE/SYSCLK,由MCO选择器来选择。

研究过时钟来源,再来研究时钟的去向,MCU自身要能正常运作,即需要一个时钟,这个时钟既是系统时钟(SYSCLK),而基本上所有外设的时钟均来自于这个系统时钟(SYSCLk)。然后由系统时钟对外提供各种外设时钟。详见图。

当然,也有例外,USB时钟必须为48MHZ,这里的USB时钟(USBCLK)由PLLCLK直接提供,RTC时钟(RTCCLK)也不是来源于系统时钟(SYSCLK),详见图。

时钟结构大体也就如此,不再深究,网上有许多更加深入的讲解,接下来说说如何去配置。用代码来说明问题:

先贴文件“system_stm32f10x.c”,此文件即库文件。里面有一个很重要的函数“SystemInit()”

解析过STM32启动代码的朋友都应该知道,这个函数跑在进入main函数之前,里面做的事情即是配置系统时钟。代码如下:

voidSystemInit(void){/*ResettheRCCclockconfigurationtothedefaultresetstate(fordebugpurpose)*//*SetHSIONbit

STM32F10主控芯片大全:

型号Description
STM32F103VBMainstream Performance line, ARM Cortex-M3 MCU with 128 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103VEMainstream Performance line, ARM Cortex-M3 MCU with 512 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103R6Mainstream Performance line, ARM Cortex-M3 MCU with 32 Kbytes Clash, 72 MHz CPU, motor control, USB and CAN
STM32F103ZEMainstream Performance line, ARM Cortex-M3 MCU with 512 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103ZGMainstream Performance line, ARM Cortex-M3 MCU with 1 Mbyte Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103CBMainstream Performance line, ARM Cortex-M3 MCU with 128 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103R8Mainstream Performance line, ARM Cortex-M3 MCU with 64 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F100C8Mainstream Value line, ARM Cortex-M3 MCU with 64 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F100R8Mainstream Value line, ARM Cortex-M3 MCU with 64 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F103VCMainstream Performance line, ARM Cortex-M3 MCU with 256 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103VGMainstream Performance line, ARM Cortex-M3 MCU with 1 Mbyte Flash, 72 MHz CPU, motor control, USB and CAN
STM32F105VCMainstream Connectivity line, ARM Cortex-M3 MCU with 256 Kbytes Flash, 72 MHz CPU, CAN, USB 2.0 OTG
STM32F100RBMainstream Value line, ARM Cortex-M3 MCU with 128 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F100VCMainstream value line, ARM Cortex-M3 MCU with 256 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F103C6Mainstream Performance line, ARM Cortex-M3 MCU with 32 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103RBMainstream Performance line, ARM Cortex-M3 MCU with 128 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103VDMainstream Performance line, ARM Cortex-M3 MCU with 384 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103ZCMainstream Performance line, ARM Cortex-M3 MCU with 256 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103ZDMainstream Performance line, ARM Cortex-M3 MCU with 384 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103ZFMainstream Performance line, ARM Cortex-M3 MCU with 768 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F105RCMainstream Connectivity line, ARM Cortex-M3 MCU with 256 Kbytes Flash, 72 MHz CPU, CAN, USB 2.0 OTG
STM32F100CBMainstream Value line, ARM Cortex-M3 MCU with 128 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F100R6Mainstream Value line, ARM Cortex-M3 MCU with 32 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F100RDMainstream Value line, ARM Cortex-M3 MCU with 384 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F100REMainstream Value line, ARM Cortex-M3 MCU with 512 Kbytes, 24 MHz CPU, motor control and CEC functions
STM32F100VDMainstream Value line, ARM Cortex-M3 MCU with 384 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F100VEMainstream Value line, ARM Cortex-M3 MCU with 512 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F101C8Mainstream Access line, ARM Cortex-M3 MCU with 64 Kbytes Flash, 36 MHz CPU
STM32F101CBMainstream Access line, ARM Cortex-M3 MCU with 128 Kbytes Flash, 36 MHz CPU
STM32F101R6Mainstream Access line, ARM Cortex-M3 MCU with 32 Kbytes Flash, 36 MHz CPU
STM32F103C8Mainstream Performance line, ARM Cortex-M3 MCU with 64 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103R4Mainstream Performance line, ARM Cortex-M3 MCU with 16 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103RCMainstream Performance line, ARM Cortex-M3 MCU with 256 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103REMainstream Performance line, ARM Cortex-M3 MCU with 512 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103RFMainstream Performance line, ARM Cortex-M3 MCU with 768 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103RGMainstream Performance line, ARM Cortex-M3 MCU with 1 Mbyte Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103T8Mainstream Performance line, ARM Cortex-M3 MCU with 64 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103V8Mainstream Performance line, ARM Cortex-M3 MCU with 64 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F105V8Mainstream Connectivity line, ARM Cortex-M3 MCU with 64 Kbytes Flash, 72 MHz CPU, CAN, USB 2.0 OTG
STM32F105VBMainstream Connectivity line, ARM Cortex-M3 MCU with 128 Kbytes Flash,72 MHz CPU, CAN, USB 2.0 OTG
STM32F107VCMainstream Connectivity line, ARM Cortex-M3 MCU with 256 Kbytes Flash, 72 MHz CPU, Ethernet MAC, CAN and USB 2.0 OTG
STM32F100C4Mainstream Value line, ARM Cortex-M3 MCU with 16 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F100C6Mainstream Value line, ARM Cortex-M3 MCU with 32 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F100R4Mainstream Value line, ARM Cortex-M3 MCU with 16 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F100V8Mainstream Value line, ARM Cortex-M3 MCU with 64 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F100VBMainstream Value line, ARM Cortex-M3 MCU with 128 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F100ZEMainstream Value line, ARM Cortex-M3 MCU with 512 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F101C6Mainstream Access line, ARM Cortex-M3 MCU with 32 Kbytes Flash, 36 MHz CPU
STM32F101RBMainstream Access line, ARM Cortex-M3 MCU with 128 Kbytes Flash, 36 MHz CPU
STM32F101RCMainstream Access line, ARM Cortex-M3 MCU with 256 Kbytes Flash, 36 MHz CPU
STM32F101T6Mainstream Access line, ARM Cortex-M3 MCU with 32 Kbytes Flash, 36 MHz CPU
STM32F102C6Mainstream USB Access line, ARM Cortex-M3 MCU with 32 Kbytes Flash, 48 MHz CPU, USB FS
STM32F103RDMainstream Performance line, ARM Cortex-M3 MCU with 384 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103T6Mainstream Performance line, ARM Cortex-M3 MCU with 32 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103TBMainstream Performance line, ARM Cortex-M3 MCU with 128 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103VFMainstream Performance line, ARM Cortex-M3 MCU with 768 Kbytes Flash, 72MHz CPU, motor control, USB and CAN
STM32F105R8Mainstream Connectivity line, ARM Cortex-M3 with 64 Kbytes Flash, 72 MHz CPU, CAN, USB 2.0 OTG
STM32F105RBMainstream Connectivity line, ARM Cortex-M3 MCU with 128 Kbytes Flash, 72 MHz CPU, CAN, USB 2.0 OTG
STM32F107RBMainstream Connectivity line, ARM Cortex-M3 MCU with 128 Kbytes Flash, 72 MHz CPU, Ethernet MAC, CAN and USB 2.0 OTG
STM32F107RCMainstream Connectivity line, ARM Cortex-M3 MCU with 256 Kbytes Flash, 72 MHz CPU, Ethernet MAC, CAN and USB 2.0 OTG
STM32F107VBMainstream Connectivity line, ARM Cortex-M3 MCU with 128 Kbytes Flash, 72 MHz CPU, Ethernet MAC, CAN and USB 2.0 OTG
STM32F100RCMainstream Value line, ARM Cortex-M3 MCU with 256 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F100ZDMainstream Value line, ARM Cortex-M3 MCU with 384 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F101R8Mainstream Access line, ARM Cortex-M3 MCU with 64 Kbytes Flash, 36 MHz CPU
STM32F101RDMainstream Access line, ARM Cortex-M3 MCU with 384 Kbytes Flash, 36 MHz CPU
STM32F101REMainstream Access line, ARM Cortex-M3 MCU with 512 Kbytes Flash, 36 MHz CPU
STM32F101RGMainstream Access line, ARM Cortex-M3 MCU with 1 Mbyte Flash, 36 MHz CPU
STM32F101T4Mainstream Access line, ARM Cortex-M3 MCU with 16 Kbytes Flash, 36 MHz CPU
STM32F101T8Mainstream Access line, ARM Cortex-M3 MCU with 64 Kbytes Flash, 36 MHz CPU
STM32F101TBMainstream Access line, ARM Cortex-M3 MCU with 128 Kbytes Flash, 36 MHz CPU
STM32F101V8Mainstream Access line, ARM Cortex-M3 MCU with 64 Kbytes Flash, 36 MHZ CPU
STM32F101VBMainstream Access line, ARM Cortex-M3 MCU with 128 Kbytes Flash, 36 MHz CPU
STM32F101VCMainstream Access line, ARM Cortex-M3 MCU with 256 Kbytes Flash, 36 MHz CPU
STM32F101VDMainstream Access line, ARM Cortex-M3 MCU with 384 Kbytes Flash, 36 MHz CPU
STM32F101VEMainstream Access line, ARM Cortex-M3 MCU with 512 Kbytes Flash, 36 MHz CPU
STM32F102C4Mainstream USB Access line, ARM Cortex-M3 MCU with 16 Kbytes Flash, 48 MHz CPU, USB FS
STM32F102C8Mainstream USB Access line, ARM Cortex-M3 MCU with 64 Kbytes Flash, 48 MHz CPU, USB FS
STM32F102CBMainstream USB Access line, ARM Cortex-M3 MCU with 128 Kbytes Flash, 48 MHz CPU, USB FS
STM32F102RBMainstream USB Access line, ARM Cortex-M3 MCU with 128 Kbytes Flash, 48 MHz CPU, USB FS
STM32F103C4Mainstream Performance line, ARM Cortex-M3 MCU with 16 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F103T4Mainstream Performance line, ARM Cortex-M3 MCU with 16 Kbytes Flash, 72 MHz CPU, motor control, USB and CAN
STM32F101VFMainstream Access line, ARM Cortex-M3 MCU with 768 Kbytes Flash, 36 MHz CPU
STM32F100ZCMainstream Value line, ARM Cortex-M3 MCU with 256 Kbytes Flash, 24 MHz CPU, motor control and CEC functions
STM32F101C4Mainstream Access line, ARM Cortex-M3 MCU with 16 Kbytes Flash, 36 MHz CPU
STM32F101R4Mainstream Access line, ARM Cortex-M3 MCU with 16 Kbytes Flash, 36 MHz CPU
STM32F101RFMainstream Access line, ARM Cortex-M3 MCU with 768 Kbytes Flash, 36 MHz CPU
STM32F101VGMainstream Access line, ARM Cortex-M3 MCU with 1 Mbyte Flash, 36 MHz CPU
STM32F101ZCMainstream Access line, ARM Cortex-M3 MCU with 256 Kbytes Flash, 36 MHz CPU
STM32F101ZDMainstream Access line, ARM Cortex-M3 MCU with 384 Kbytes Flash, 36 MHz CPU
STM32F101ZEMainstream Access line, ARM Cortex-M3 MCU with 512 Kbytes Flash, 36 MHz CPU
STM32F101ZFMainstream Access line, ARM Cortex-M3 MCU with 768 Kbytes Flash, 36 MHz CPU
STM32F101ZGMainstream Access line, ARM Cortex-M3 MCU with 1 Mbyte Flash, 36 MHz CPU
STM32F102R4Mainstream USB Access line, ARM Cortex-M3 MCU with 16 Kbytes Flash, 48 MHz CPU, USB, FS
STM32F102R6Mainstream USB Access line, ARM Cortex-M3 MCU with 32 Kbytes Flash, 48 MHz CPU, USB FS
STM32F102R8Mainstream USB Access line, ARM Cortex-M3 MCU with 64 Kbytes Flash, 48 MHz CPU, USB FS


责任编辑:David

【免责声明】

1、本文内容、数据、图表等来源于网络引用或其他公开资料,版权归属原作者、原发表出处。若版权所有方对本文的引用持有异议,请联系拍明芯城(marketing@iczoom.com),本方将及时处理。

2、本文的引用仅供读者交流学习使用,不涉及商业目的。

3、本文内容仅代表作者观点,拍明芯城不对内容的准确性、可靠性或完整性提供明示或暗示的保证。读者阅读本文后做出的决定或行为,是基于自主意愿和独立判断做出的,请读者明确相关结果。

4、如需转载本方拥有版权的文章,请联系拍明芯城(marketing@iczoom.com)注明“转载原因”。未经允许私自转载拍明芯城将保留追究其法律责任的权利。

拍明芯城拥有对此声明的最终解释权。

标签: STM32 MCU

相关资讯