STM32学习记录(1)

STM32 GPIO上拉电阻选型:阻值选择全面讲解 深入讲解STM32 GPIO中上拉电阻的选型方法,结合实际应用场景分析不同阻值对信号稳定性与功耗的影响,帮助开发者合理选用上拉电阻,提升电路可靠性与系统性能。 阅读详情

学习记录

下面是本人的学习记录,有错误的地方欢迎大家评论区提出来。


1.同时控制同个端口的多个LED,在初始化的时候,使用或运算符"|",就不用再cv一份代码进行初始化了。

2.LED,发光二极管
二极管:压降,经过自己的时侯电压会自动降低额定的伏数,0.3V或0.7v,
电流不能大于10mA,
限流电阻最小值=( 3300-300)/10 = 300欧姆。

3.引脚悬空
答:那么电阻约等于无限大,且静电积累会造成影响,导致引脚损坏。

4.按键设计的时候,为什么要加一个上拉电阻呢?而且电阻阻值设置为10K?
答:给单片机输入一个确定的电平,不加上拉电阻,单片机的输入电压没有一个参考对象,无法准确地判断为高电平还是低电平。接地,地为参考对象,则为低电平,接VCC,有个上拉电阻,上拉电阻为参考对象,为高电平。同时,也增加了抗干扰能力。

5.推挽输出作用
答:提高驱动电流。

6.上拉电阻设置为多大合适呢?
答:其实330/470/510/1K/2K /3K3/4KT/10K都是没有问题的。
但是电阻值越小,其功耗会增加,例如330欧,通过的电流则是10mA,如果是电池进行供电,那么其损耗就太大了,影响续航能力。但是电阻也不是越大越好,否则识别不了电流,所以选择一个折衷的方案,也可以说是一个经验值。
设置为10K,3.3V/10K=0.33mA。
弱上拉用10K,强一些用4.7K的。
5V一般用10K,3.3用4.7多一点。

总结:上拉电阻的选择,上拉电阻选择越大,功耗越低,但是要保证通过的电流能驱动外设和IO口,上拉电阻选择越小,功耗越大,但是要保证当为低电平时,io口端的电压要在低电平的电压值的范围之内, 经验值为4.7k到10k之间。

7.TTL识别电平如下图所示
在这里插入图片描述

<
STM32模拟I²C通信时上拉电阻的配置技巧 在STM32模拟I²C通信时,合理配置上拉电阻对信号稳定性至关重要。通过选择合适的上拉电阻阻值,可有效提升通信可靠性,避免数据出错,尤其在多设备连接时更需注意上拉电阻的影响。 阅读详情

相关推荐

从STM32的GPIO配置说起:内部上拉/下拉电阻怎么选?按键消抖又该怎么写代码?

本文深入探讨了STM32 GPIO配置中内部上拉/下拉电阻的选择策略及按键消抖的代码实现。通过分析浮空输入、上拉输入和下拉输入模式的特点,提供了按键电路设计的最佳实践,并详细介绍了三种软件消抖方案,包括简单延时法、状态机非阻塞实现和定时器中断扫描法,帮助开发者解决按键检测不稳定的问题。

weixin_32818781的博客 343

STM32cubeMX学习记录1-点亮LED

一、准备工作: 1、安装STM32cubeMX软件,注意我使用的是5.0版之前的 2、安装keil-ARM软件,注意版本最好是5.2.6以后的 3、准备一个开发板 二、点灯实验(PB5接一个LED灯,低电平灯亮,高电平灯灭) (后续涉及到多种方式操作的,只讲解一种,追求能实现目的即可) 1、打开STM32cubuMX软件 2、选择左边居中位置的“New Project”进行新...

m0_38028388的博客 1371

stm32学习开发debug记录(1)

本系列记录开发stm32过程中遇到的一系列bug,可作为日后debug时的参考,也可为同刚起步学习stm32的小白作为debug参照。 安装 (1)安装keil最新版本可参照https://www.cnblogs.com/armfly/p/12564643.html,网页中附有keil最新版本安装包和各种stm32开发所需的支持包。 注意!用购买的开发板测试时,采用过高版本的keil可能发生固件无法更新的情况,提示: The up-to-date firmware is too big for this b

Borton__的博客 1937

XC95144XL-10TQG144I Xilinx XC9500XL 高性能 CPLD

XC95144XL-10TQG144I 属于 Xilinx 的 XC9500XL 高性能 CPLD 家族,是一颗面向 3.3V 低电压系统的可编程逻辑器件。该器件以小封装、高速响应和良好的系统兼容性为设计目标,常用作系统控制/ glue-logic、I/O 缓冲、状态机、总线桥接与接口协议前端等场景中的可重编程逻辑单元。产品支持现场(in-system)编程与 IEEE-1149.1 JTAG 边界扫描,能在系统板上直接更新逻辑。

2403_90082736的博客 1055

微信小程序反编译实战:用wxappUnpacker获取他人源码的完整流程(附常见报错解决方案)

本文详细解析了微信小程序反编译的完整流程,从缓存提取到源码重构,使用wxappUnpacker工具链实现逆向工程。涵盖环境配置、解密反编译、项目调试等关键步骤,并提供了常见报错解决方案,帮助开发者学习优秀实现方案或进行安全审计。

weixin_42706667的博客 467

C#与Vector XL驱动库实战:CAN通道配置与端口访问详解

本文详细解析了使用C#调用Vector XL驱动库进行CAN总线通信开发的核心步骤。重点阐述了如何通过XL_GetDriverConfig获取硬件通道信息,并厘清channelMask与accessMask的区别与转换关系,最终指导开发者正确使用XL_OpenPort函数配置并打开CAN端口,为构建稳定的汽车电子测试与诊断应用奠定基础。

weixin_28452161的博客 360

ms17-010 永恒之蓝漏洞利用+抓包分析过程

一、实验环境: 1、攻击机:Kali 1)攻击工具:msf 2)分析工具:wireshark 3)IP地址:192.168.204.157(自动获得) 2、靶 机:Windows7 1)版本:SP1 2)开启网络共享(SMB协议) 3)关闭防火墙 4)IP地址:192.168.204.150(自动获得) 3、网卡连接方式:Vmnet8(NAT) 二、实验步骤: ...

qq_41976183的博客 6942

配电变压器测控终端装置设计

配电变压器测控终端装置在电网运行中承担着数据采集、状态监测、故障预警及远程控制的关键任务,其性能直接关系到配电系统的安全性与可靠性。本研究围绕测控终端的硬件电路、软件算法、通信系统及系统优化展开深入分析,并基于实验测试验证系统性能。硬件设计包括模拟量输入电路、电压电流信号变换电路、A/D转换电路、控制与通信电路及系统电源电路,确保信号采集的高精度与系统的稳定性。软件部分涵盖系统控制程序、数据采集与处理程序、通信程序及显示与控制程序,实现数据的实时处理与传输。通信模块结合RS-485、CAN总线及以太网技术,

weixin_44553616的博客 1099

lammps 案例:高熵合金FeNiCrCoCu建模及拉伸模拟

高熵合金力学性能模拟包括拉伸、剪切、摩擦等模拟,本文以高熵合金FeNiCrCoCu为例介绍高熵合金建模及拉伸过程模拟。 FeNiCrCoCu原子数量比为1:1:1:1:1 高熵合金的拉伸与单晶拉伸过程类似,主要包含以下步骤: 1.建模 高熵合金含有原子类型较多,建模时,一般以含量最多的原子为主建立初始模型。 使用set type/ratio或者set type/fraction的方式按一定比例替换为其它合金原子。 如随机选择20%的原子1,将其转换为原子2: set type 1 type/ratio 2

lammps_jiayou的博客 6063

【软件测试】- 公有云、私有云、混合云简介以及如何在公有云与私有云上分别搭建测试环境

公有云、私有云以及混合云是目前云计算领域的三种主要模式。它们之间的区别主要在于部署方式、数据访问和管理控制的不同。在阿里云或腾讯云上使用 Kubernetes 和 Docker 搭建测试环境可以提供高度的可伸缩性和灵活性。这样的环境非常适合于需要在多种配置和条件下进行测试的复杂应用。通过云服务提供的工具和服务,可以轻松管理和监控整个测试过程。在云服务上搭建测试环境涉及选择合适的云提供商、配置云资源、安装和设置所需软件等步骤。### 1. 选择云服务提供商。

weixin_46453070的博客 2317

华为od 面试八股文_JAVA语言_01_含答案

华为od 面试八股文_JAVA语言_01_含答案

MISAYAONE的博客 4269

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

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

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

上一篇: STM32HAL库使用DAC输出任意指定电压
下一篇: 51单片机中断地址表
墨菲墨菲
博客等级 码龄7年 174粉丝 214原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值