当前位置:网站首页>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)
边栏推荐
- 130. Surrounding area
- Common fault analysis and Countermeasures of using MySQL in go language
- 2022 examination for safety production management personnel of hazardous chemical production units and new version of examination questions for safety production management personnel of hazardous chem
- 2022 high voltage electrician examination skills and high voltage electrician reexamination examination
- 4、策略學習
- Saving and reading of network model
- 2022 tea master (intermediate) examination questions and tea master (intermediate) examination skills
- Su embedded training - C language programming practice (implementation of address book)
- Capstone/cs5210 chip | cs5210 design scheme | cs5210 design data
- Design method and application of ag9311maq and ag9311mcq in USB type-C docking station or converter
猜你喜欢

2021-03-06 - play with the application of reflection in the framework

2021 tea master (primary) examination materials and tea master (primary) simulation test questions

2021 Shanghai safety officer C certificate examination registration and analysis of Shanghai safety officer C certificate search

2022 examination for safety production management personnel of hazardous chemical production units and new version of examination questions for safety production management personnel of hazardous chem

【深度学习】AI一键换天

5. Over fitting, dropout, regularization

Chapter 7 Bayesian classifier

2022 refrigeration and air conditioning equipment operation examination questions and refrigeration and air conditioning equipment operation examination skills

2022 safety officer-b certificate examination question bank and safety officer-b certificate simulation test questions

133. 克隆图
随机推荐
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
130. Surrounding area
Recommend a document management tool Zotero | with tutorials and learning paths
133. 克隆图
Generic configuration legend
Introduction to the types and repair methods of chip Eco
2022 low voltage electrician examination content and low voltage electrician simulation examination question bank
Solve the error: NPM warn config global ` --global`, `--local` are deprecated Use `--location=global` instead.
The whole life cycle of commodity design can be included in the scope of industrial Internet
Saving and reading of network model
Ag9310 same function alternative | cs5261 replaces ag9310type-c to HDMI single switch screen alternative | low BOM replaces ag9310 design
redis的持久化方式-RDB和AOF 两种持久化机制
Su embedded training - Day6
Common configurations in rectangular coordinate system
2022 chemical automation control instrument examination summary and chemical automation control instrument simulation examination questions
Content of one frame
Parade ps8625 | replace ps8625 | EDP to LVDS screen adapter or screen drive board
Leetcode notes No.21
Know how to get the traffic password
Chapter IV decision tree