当前位置:网站首页>STM32GPIO口的工作原理
STM32GPIO口的工作原理
2022-07-07 23:23:00 【一骜】
stm32f4有7组IO口,每组有16个IO口,GPIO的的引脚与外部设备连接,可以实现与外部的通信,控制外部硬件,采集外部硬件数据的功能,与之对应的常见应用分别为串口,电机 ,ADC采集。
GPIO口的基本结构
每个GPIO口的内部都有这样一个电路图
GPIO有四种输入模式(浮空输入,上拉输入,下拉输入,模拟输入),四种输出模式(开漏输出,开漏复用输出,推挽输出,推挽复用输出)。
此外,GPIO在输出模式下支持三种翻转速度2MHz,10MHz,50MHz,在不要求转换速度很快的情况下,一般采用低速,目的是节省功耗。但是在通信协议中一般采用50MHz,
GPIO_Mode_AIN 模拟输入
GPIO_Mode_IN_FLOATING 浮空输入
GPIO_Mode_IPD 下拉输入
GPIO_Mode_IPU 上拉输入
GPIO_Mode_Out_OD 开漏输出
GPIO_Mode_Out_PP 推挽输出
GPIO_Mode_AF_OD 复用开漏输出
GPIO_Mode_AF_PP 复用推挽输出
浮空输入
浮空输入模式下,外部电平直接输入数据寄存器,也就是说,IO口输入多少的电平,CPU会读取多少的电平,在引脚悬空,没有信号输入的前提下,读取端口的电平不确定。
上拉输入
上拉输入模式下,IO口的数据信号直接进入数据寄存器,但在没有输入情况下,输入端电平保持在高电平。
下拉模式
下拉输入模式下,IO口的数据信号直接进入数据寄存器,但在没有输入情况下,输入端电平保持在低电平。
模拟输入
在模拟模式下,IO口的模拟信号(电压信号)直接模拟输入到片上外设模块。
如何选择IO口模式
浮空输入_IN_FLOATING ——浮空输入,可以做KEY识别,RX1
带上拉输入_IPU——IO内部上拉电阻输入
带下拉输入_IPD—— IO内部下拉电阻输入
模拟输入_AIN ——应用ADC模拟输入,或者低功耗下省电
开漏输出_OUT_OD ——IO输出0接GND,IO输出1,悬空,需要外接上拉电阻,才能实现输出高电平。当输出为1时,IO口的状态由上拉电阻拉高电平,但由于是开漏输出模式,这样IO口也就可以由外部电路改变为低电平或不变。可以读IO输入电平变化,实现C51的IO双向功能
推挽输出_OUT_PP ——IO输出0-接GND, IO输出1 -接VCC,读输入值是未知的
复用功能的推挽输出_AF_PP ——片内外设功能(I2C的SCL、SDA)
复用功能的开漏输出_AF_OD——片内外设功能(TX1、MOSI、MISO.SCK.SS)
边栏推荐
- Ag9311maq design 100W USB type C docking station data | ag9311maq is used for 100W USB type C to HDMI with PD fast charging +u3+sd/cf docking station scheme description
- Content of one frame
- 5. Over fitting, dropout, regularization
- Redis 主从复制
- Transportation, new infrastructure and smart highway
- 133. Clone map
- EDP to LVDS conversion design circuit | EDP to LVDS adapter board circuit | capstone/cs5211 chip circuit schematic reference
- Guojingxin center "friendship and righteousness" - the meta universe based on friendship and friendship, and the parallel of "honguniverse"
- The communication clock (electronic time-frequency or electronic time-frequency auxiliary device) writes something casually
- General configuration toolbox
猜你喜欢
130. 被围绕的区域
Arm bare metal
Application of state mode in JSF source code
2、TD+Learning
5. Contrôle discret et contrôle continu
2022 high voltage electrician examination skills and high voltage electrician reexamination examination
Chapter XI feature selection
The examination contents of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge) in 2021 and the free examination questions of the third batch of Guangdong Prov
Redis 主从复制
Several frequently used OCR document scanning tools | no watermark | avoid IQ tax
随机推荐
Redis master-slave replication
Complete model verification (test, demo) routine
完整的模型验证(测试,demo)套路
133. Clone map
Continued from the previous design
Chapter 5 neural network
Ag9310 same function alternative | cs5261 replaces ag9310type-c to HDMI single switch screen alternative | low BOM replaces ag9310 design
Using GPU to train network model
Guojingxin center "friendship and righteousness" - the meta universe based on friendship and friendship, and the parallel of "honguniverse"
The whole life cycle of commodity design can be included in the scope of industrial Internet
swift获取url参数
Overall introduction of the project
2、TD+Learning
Transportation, new infrastructure and smart highway
2021-03-06 - play with the application of reflection in the framework
Cross modal semantic association alignment retrieval - image text matching
Micro rabbit gets a field of API interface JSON
Scheme selection and scheme design of multifunctional docking station for type C to VGA HDMI audio and video launched by ange in Taiwan | scheme selection and scheme explanation of usb-c to VGA HDMI c
Share a latex online editor | with latex common templates
Generic configuration legend