STM32时钟初始化研究

STM32 系统时钟设置 1、使用3.5.0的库,系统自动设置为外部时钟8M的时钟,72M工作频率,无需再进行配置。 2、若要自定义时钟时不要用SystemInit函数,把启动代码的SystemInit函数注释掉,main函数加这个RCC配置函数 Reset_Handler   PROC                  EXPORT  Reset_Handler             [WEAK]    阅读详情
时钟是一个MCU的脉搏,研究清楚脉搏才能更清楚的把握整个MCU的运行。本文主要研究STM32F10x系列,利用官方库文件进行初始化设置。开发环境为MDK4.6,库文件V3.5版本,STM32参考手册。

利用MDK自带仿真器,仿真发现。芯片启动首先打开system_stmf10x.c文件,调用void SystemInit(void)函数。下面贴上代码和中文注释

void SystemInit (void)
{
	/* Reset the RCC clock configuration to the default reset state(for debug purpose) */
	/* Set HSION bit */
	RCC->CR |= (uint32_t)0x00000001;	//内部高速时钟使能
	
	
	/* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */
	//SW:HSI(内部高速8M RC震荡器)作为时钟源
	//AHB(SYSCLK)不分频
	//APB1,APB2不分频
	// PCLK2 2分频后作为ADC时钟
	// HSI时钟2分频后作为PLL输入时钟
	//MCO没有时钟输出
	RCC->CFGR &= (uint32_t)0xF8FF0000;

	
	/* Reset HSEON, CSSON and PLLON bits */
	//HSE振荡器关闭, 时钟安全系统监测器关闭PLL关闭
	RCC->CR &= (uint32_t)0xFEF6FFFF;


	/* Reset HSEBYP bit *
keil 仿真卡在Wait till HSE is ready and if Time out is reached exit keil 仿真卡在Wait till HSE is ready and if Time out is reached exit /* Wait till HSE is ready and if Time out is reached exit */ do { HSEStatus = RCC->CR & RCC_CR_HSERDY; StartUpCounter++; } while((HSEStatus == 0) && (StartUpCounte 阅读详情

相关推荐

【单片机学习之旅】(2-1)stm32f4时钟系统及初始化过程

时钟是单片机的心脏,而时钟系统就像是全身的血管,在时钟系统的工作下,单片机各个部位按需求的正常工作。今天写一写我对stm32f4xx时钟系统及初始化的理解。在stm32中系统时钟是通过获得的时钟源经过分频倍频等操作而来的,而时钟源有以下几种: 1.外部高速时钟(HSE):其实就是单片机板子上的晶振电路,用户决定的 2.内部高速时钟(HSI):这是单片机内部自带的振荡器,精度没有石英晶振高,易受温度影响 3.主PLL时钟:其实就是将HSE/HSI倍频后的时钟,可以不选择,直接使用HSE/HSI 4.32 kH

qq_61644450的博客 3785

STM32H743串口1-8初始化和使用DMA数据传输

按照正点原子例程,STM32H743能够使用的串口有9个,8个普通串口和1个低功耗串口,在这里作者只对串口1-8进行研究。串口1和串口6的时钟势=使能在APB2ENR寄存器,其他串口的时钟使能都是在APB1ENR寄存器。这样就可以使用DMA进行串口数据的发送了,注意映射关系!首先是串口1-8的初始化,串口1的初始化。

weixin_42833640的博客 861

STM32—时钟树(结合系统时钟函数理解)

时钟树的概念: 我们可以把MCU的运行比作人体的运行一样,人最重要的是什么?是心跳! 心脏的周期性收缩将血液泵向身体各处。心脏对于人体好比时钟对于MCU,微控制器(MCU)的运行要靠周期性的时钟脉冲来驱动,而这个脉冲的始源往往是由外部晶体振荡器提供时钟输入,最终转换为多个外部设备的周期性运作。这种时钟“能量”的传递路径犹如大树的养分由主干流向个分支,因此称为时钟树。 STM32时钟: 在STM32...

肥宅快乐博客 1万+

STM32各外设初始化步骤

STM32外设初始化流程,GPIO,AFIO,TIM,NVIC,EXTI等外设初始化,持续更新。

lanzh_syf的博客 7142

基于STM32的电子时钟设计

基于STM32的电子时钟设计1、设计目的2、设计具体要求3、proteus仿真图4、程序代码 1、设计目的 (1)掌握使用KEIL MDK5进行软件开发的具体流程; (2)掌握硬件电路的设计方法; (3)掌握STM32微控制器的程序设计及代码编写方法。 2、设计具体要求 (1)通过STM32自带的实时时钟功能获取时间信息; (2)在OLED显示屏上显示日期、时、分、秒等时间信息; (3)通过按键可对时间信息进行修改; (4)具有闹钟设定功能; (5)加分项:自行增加其他功能。 3、proteus仿真图 4

唯一的博客 2万+

STM32之RTC实时时钟

STM32之RTC实时时钟

weixin_52483742的博客 5975

【STM32】SystemInit时钟系统初始化函数剖析

本文介绍了STM32微控制器的时钟系统,重点解析了五种主时钟源(HSI、HSE、LSI、LSE、PLL)的特性及应用场景。文章详细说明了系统时钟初始化流程,包括SystemInit函数的作用、时钟配置寄存器解析,以及PLL倍频原理。针对关键问题"为何使用外设前需初始化时钟",文中指出所有外设必须使能时钟才能正常工作,并提供了GPIO和定时器的时钟使能示例。最后给出了完整的时钟配置推荐流程,涵盖时钟源选择、PLL设置、Flash延迟配置等关键步骤,为STM32开发者提供了实用的时钟系统参考指南。

猫猫的小茶馆 1635

STM32之RTC时钟

前言 了解实时时钟RTC的原理。STM32芯片自带RTC,因此不须像其他MCU需外接RTC模块。请编程实现STM32的日历读取、设置和输出。要求: 1)读取RTC初始时间,验证是否为 1970年1月1日零分零秒; 2)将RTC时间调整为当前时间,并以 2021年x月x日x分x秒的格式从串口输出(或输出到OLED屏),每1s改变一次; 3)如果输出内容中需加入“星期x”,请修改代码。 一.RTC时钟介绍 RTC (Real Time Clock):实时时钟 RTC是个独立的定时器。..

IT23131的博客 5594

STM32L4系列一、时钟系统简介

跟着原子哥学习,顺便写点笔记~ 主要内容 1)STM32L4 时钟树概述; 2)STM32L4 时钟初始化配置; 3)STM32L4 时钟使能和配置。 一、STM32L4 时钟树概述 时钟系统是 CPU 的脉搏,重要性不言而喻。不同于51单片机一个系统时钟解决一切问题,STM32 有多个时钟源。这是因为STM32本身的外设非常多,但并不是所有外设都需要系统时钟这么高的频率,比如看门狗以及 RTC 只需几十 k 的时钟即可。同一个电路,时钟越快功耗越大,同时抗电磁干扰能力也会越弱,所以对于较为复杂的 MCU

Leisure_ksj的博客 4792

别再只当代码阅读器了!手把手教你用Understand的实体定位器和信息浏览器,5分钟精准定位代码逻辑

本文深入解析Understand代码分析工具的高级功能,重点介绍实体定位器和信息浏览器的实战应用。通过5分钟快速定位代码逻辑的技巧,帮助开发者从代码阅读者升级为逻辑侦探,提升大型代码库的分析效率。文章包含过滤搜索、调用链追踪等实用方法,是掌握Understand核心功能的必备指南。

weixin_28745821的博客 291

BMS | 从一串到几百串硬件架构简介

锂电池在生活中越来越多的方面扮演能源的角色,除了大家熟知的电动汽车行业,在一些消费类,工业类电子产品比如手机,电动自行车,电动工具中都有应用,追本溯源今天我们一起来学习下最基础的BMS架构。 1~4串架构 以S8241为代表的无通信/无固件/模拟器件 可实现过充保护、过放保护、过流/短路,参数由器件后缀代码决定;通信类手持设备供电系统;1~4节电池保护板架构 如图使用S-8241系列保护IC,一对充放电MOS管控制充放电的回路的切断和接通,系统供电来自于电芯电压,VM引脚用于检测过...

ningvay的博客 9916

Cadence 17.2配置CIS数据库报错?手把手解决ODBC驱动位数不匹配问题

本文详细解析了Cadence 17.2配置CIS数据库时常见的ODBC驱动位数不匹配问题,提供了从系统环境检查到分步解决方案的完整指南。重点解决32位应用程序与64位ODBC驱动之间的架构冲突,包含驱动安装、DSN配置及高级排查技巧,帮助电子工程师快速恢复设计环境。

play7的博客 970

人工智能在高中教育中的应用现状剖析与挑战应对

人工智能在高中教育中的应用现状剖析与挑战应对

燕鹏 1338

用Scratch实现凯撒密码:图形化编程与古典密码学的趣味结合

字符编码与移位运算是计算机处理文本数据的基础原理之一,它通过将字母映射为数字实现信息转换。在密码学领域,凯撒密码作为最经典的替换密码,直观地展示了基于规则字符替换的加密思想,其核心价值在于通过简单算法揭示加密解密的基本框架。这种原理在编程教育中尤为重要,能够帮助初学者理解循环、变量和字符串处理等核心概念。结合Scratch图形化编程环境,学习者可以通过拖拽积木可视化构建加密算法,将抽象的移位操作转化为交互式游戏。本项目以凯撒密码为例,通过实时密钥调整和动态字母表映射,生动演示加密过程,并自然融入暴力破解和密

weixin_32428571的博客 309

SCI投稿Title Page、Cover letter、Highlights、Manuscript模板

(简要介绍一下论文的创新性). I hope this paper issuitable for “Journal Name”.版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。原文链接:https://blog.youkuaiyun.com/weixin_48615832/article/details/120317336。

qq_15963745的博客 3699

基于YOLOv8深度学习架构的智能农业巡检小车系统—面向农作物与杂草实时精准识别的创新实践

本研究设计并实现了一套基于YOLOv8的智能农业巡检小车系统,解决农田中农作物与杂草的精准识别与追踪问题。系统采用改进YOLOv8-RGCSPELAN-ECA-AFPN模型,融合ECA注意力机制与AFPN多尺度特征融合结构,提升复杂环境下的检测精度。硬件以树莓派4B为核心,集成摄像头、传感器与电机模块,具备避障、循迹与自主导航功能。移动端基于Android部署NCNN推理引擎,实现模型高效移植与实时检测。

Stara-AI的博客 1423

【100%通过率】华为OD机试真题 Java&Go 实现【水库蓄水问题】【2022.11 Q4 新题】

给定一个长度为 n 的整数数组height。数组的元素表示山的高度,选择两个元素作为水库的边界,求蓄水量的最大值并输出蓄水量最大时的边界下标(蓄水量相同时输出下标较近的)。

MISAYAONE的博客 1万+

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

上一篇: C程序设计语言(第2版)读书笔记
下一篇: STM32时钟安全机制(CSS)研究及实现
notepi
博客等级 码龄15年 23粉丝 32原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值