STM32-02基于HAL库(CubeMX+MDK+Proteus)GPIO输出案例(LED流水灯)

STM 32简单编程实例 这里写目录标题一、STM 32程序1.建立一个工程文件2.选择STM32芯片3.对所选芯片进行设置4.编写源程序5.编译结果二、程序的仿真调试1.仿真前的设置(1)点击魔法棒,进入设置界面(2) 进入debug界面,左侧选择Use Simulator,右侧选择ULINK2/ME Cortex Debugger,最后点击Settings(3) 进入setting界面,选择Autodelect2.开始调试三、总结 一、STM 32程序 1.建立一个工程文件 2.选择STM32芯片 3.对所选芯片进行设置 阅读详情

一、功能需求分析

在完成开发环境搭建之后,开始使用STM32GPIO的功能,可以看到上次测试案例,LED点亮实验,在其基础上,调用HAL库的读写引脚,反转引脚状态的API函数,实现流水灯效果。

需求分析:

  1. 使用PA0-PA3引脚,分别连接LED0-3;
  2. 实现回马枪样式的流水灯效果,首先LED0-3依次点亮,然后LED3-0逆序点亮;
  3. LED使用低电平驱动方式;
  4. 为了演示效果,四个LED选取不同的颜色。

二、Proteus绘制电路原理图

绘制电路原理图的步骤:创建画布=》芯片选型及放置=》元器件选型及放置=》连接电路=》修改元器件参数=》仿真运行。

下图为绘制LED所需元器件清单。
在这里插入图片描述

下图为按键检测案例的电路原理图。
在这里插入图片描述
注意,此处的LED为低电平驱动方式,即引脚输出0点亮,输出1熄灭。

三、STMCubeMX 配置引脚及模式,生成代码

接下来,根据原理图绘制,创建CubeMX项目,配置引脚及工作模式,生成MDK项目代码。

创建项目,在Pinout配置模块,点击PA0,选择GPIO_Output推挽输出模式,同理,配置PA1。

Stm32f103c8t6(proteus仿真)学习——1.点亮LED流水灯 1.点亮一个LED灯 阅读详情

相关推荐

用STM32F103C8芯片做流水灯

目录 一、STM32F103C8T6简介 二、使用寄存器点亮LED灯 1.工程模板的建立 2.建立工程 3.主要函数代码 4.编译生成HEX文件 5.电路搭建 6.用串口下载程序 7.实验结果 一、STM32F103C8T6简介 根据STM32&STM8产品型号命名规则(参考:STM32单片机最小系统详解)可知: STM32F103C8T6这个命名中:STM32代表STM32家族,32位MCUF代表产品类型为基础型; 103代表特定功能为STM32基础型;...

m0_61811389的博客 1327

嵌入式——基于HAL库和中断的LED流水灯

STM32微控制器具有丰富的中断系统,能够处理各种内部和外部事件;HAL库通过提供统一的API来抽象硬件细节, 使得开发者不需要直接操作寄存器,从而简化了代码的编写和维护;Proteus 8.15 是一个强大的工具,对于学习和开发嵌入式系统非常有用。通过它,用户可以在没有实际硬件的情况下测试和验证电路设计。

2301_78300727的博客 2339

STM32F4 HAL流水灯Proteus仿真

STM32F4 HAL流水灯Proteus仿真

高效数据迁移:ICCAP到ADS的数据导入与导出实战指南

本文提供了从ICCAP到ADS进行高效、准确数据迁移的实战指南。针对射频与微波电路设计中的关键挑战,详细阐述了迁移前的战略规划、ICCAP数据的精细化导出(包括脚本化批处理)、ADS数据的多种导入方法(如Data Items、DML模型库及编程化API),并强调了数据完整性与准确性验证的重要性,确保模型参数和仿真结果在平台间可靠传递。

weixin_29291185的博客 131

【Zephyr 系列 29】低功耗调试指南:电流测量、系统睡眠与功耗分析

Zephyr低功耗调试指南(150字摘要) 针对物联网设备续航需求,本文解析Zephyr低功耗调试方法:1️⃣ 机制:启用PM子系统和tickless idle,配置睡眠策略;2️⃣ 测量:推荐功耗分析仪捕捉μA级电流波动;3️⃣ 优化:管理唤醒源(如GPIO/RTC)、调整BLE广播/连接参数,挂起闲置外设;4️⃣ 分析:建立功耗文档,对比不同模式电流(如待机0.6mA vs广播3.2mA)。强调低功耗需系统性设计,初期即需纳入测试流程。下期将探讨Zephyr OTA升级实现。

hemoparrot的专栏 1180

中兴畅行60 ZTE 7552N 深度改造指南:从解锁BL到Magisk Root与IMEI硬改全流程

本文详细介绍了中兴畅行60(ZTE 7552N)的深度改造全流程,包括解锁BL、刷入Magisk获取Root权限以及IMEI硬改等关键步骤。通过专业的操作指南和实用技巧,帮助用户安全完成设备改造,同时提醒注意法律风险和技术难点。

weixin_33670786的博客 1887

自定义串口通讯协议

自定义串口通讯协议的实现方法

qq_44826038的博客 2172

TP4056在单节锂电池充电管理中的创新应用与电路优化

本文深入探讨了TP4056线性充电管理芯片在单节锂电池充电电路中的创新应用与优化方案。针对“边充边用”的核心挑战,文章详细解析了利用PMOS管构建智能供电切换电路的原理,实现了外部电源与电池供电的无缝、安全切换,有效杜绝了电池“边充边放”的风险。同时,提供了关键的元器件选型、PCB布局布线技巧及常见问题排查指南,为创客和硬件开发者提供了高性价比、高可靠性的锂电池电源管理实践方案。

rock5的博客 501

IC 笔试真题之吾见——华为实习(1)

前言 今天(2022 04 07)刚建立了一个专栏《IC真题之吾见》,准备记录一些IC真题的见解,为以后找工作做一点准备。 刷题绝不是目的,以题代练,以题代学。 题目来自师兄申请 华为实习“设计”岗位 的笔试真题。 见解大部分来自自己学习的理解,也有部分超纲知识是网络检索得到,希望可以多多在评论区留言交流,共同进步! 有问题的地方也希望可以直接批评指正! 后面也会同步更新此专栏! 1、下列有关时序分析的描述正确的是() A. recovery时间,是指异步控制信号在有效时钟沿到达之后必须保持

记录所学,分享知识,结识挚友 8637

DaVinci Developer和DaVinci Configurator:AutoSAR开发与配置工具

a. 组件创建:DaVinci Developer允许开发人员创建不同类型的AutoSAR软件组件,如应用软件组件(Application Software Component,SWC)、基础软件组件(Basic Software Component,BSWC)等。除了以上功能,DaVinci Developer和DaVinci Configurator还提供了丰富的文档和代码生成功能,以支持开发人员和配置人员进行文档编写、代码生成和文档浏览等任务。用户可以根据具体需求对软件组件进行灵活的配置。

HmoaAmp的博客 2262

RH850从0搭建Autosar开发环境【3X】- Davinci Configurator之OS模块配置详解(中)

RH850从0搭建Autosar开发环境【3X】- Davinci Configurator之OS模块配置详解(中)

weixin_42412049的博客 1513

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

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

深度学习工具包 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")

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

上一篇: STM32-01基于HAL库(CubeMX+MDK+Proteus)仿真开发环境搭建(LED点亮测试实例)
下一篇: STM32-03基于HAL库(CubeMX+MDK+Proteus)输入检测案例(按键控制LED)
Empty_Android
博客等级 码龄10年 98粉丝 45原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值