当前位置:网站首页>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)
边栏推荐
- 5. Over fitting, dropout, regularization
- Guojingxin center "friendship and righteousness" - the meta universe based on friendship and friendship, and the parallel of "honguniverse"
- How to get the first and last days of a given month
- 130. Surrounding area
- Serial port receives a packet of data
- Design method and reference circuit of type C to hdmi+ PD + BB + usb3.1 hub (rj45/cf/tf/ sd/ multi port usb3.1 type-A) multifunctional expansion dock
- 2022 safety officer-c certificate examination summary and safety officer-c certificate reexamination examination
- 2021 Shanghai safety officer C certificate examination registration and analysis of Shanghai safety officer C certificate search
- Basic realization of line graph
- Complete model training routine
猜你喜欢

On the concept and application of filtering in radar signal processing

Markdown learning (entry level)

Ag7120 and ag7220 explain the driving scheme of HDMI signal extension amplifier | ag7120 and ag7220 design HDMI signal extension amplifier circuit reference

How to write mark down on vscode

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

133. 克隆图

Transportation, new infrastructure and smart highway

Smart grid overview

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

Su embedded training - Day9
随机推荐
2、TD+Learning
Recommend a document management tool mendely Reference Manager
2022 safety officer-c certificate examination paper and safety officer-c certificate simulated examination question bank
8. Optimizer
Complete model verification (test, demo) routine
跨模态语义关联对齐检索-图像文本匹配(Image-Text Matching)
2021-04-12 - new features lambda expression and function functional interface programming
133. Clone map
String usage in C #
2021-03-06 - play with the application of reflection in the framework
130. 被圍繞的區域
A little experience from reading "civilization, modernization, value investment and China"
Su embedded training - Day6
Su embedded training - Day5
完整的模型训练套路
Common fault analysis and Countermeasures of using MySQL in go language
Ag9310 same function alternative | cs5261 replaces ag9310type-c to HDMI single switch screen alternative | low BOM replaces ag9310 design
Codeforces Round #804 (Div. 2)
Frequency probability and Bayesian probability
2022 low voltage electrician examination content and low voltage electrician simulation examination question bank