当前位置:网站首页>Embedded Systems: GPIO
Embedded Systems: GPIO
2022-08-03 22:10:00 【TUTUATM】
GPIO
通用输入输出端口
GPIO是MCUThe only interface with external contact,外部设备通过GPIO与MCU之间通信
(一)输入输出模块
1.输入模块(input driver)
(1)浮空输入
(2)上拉输入
(3)下拉输入
(4)模拟输入
2.输出模块(output driver)
(1)推挽输出
(2)推挽复用输出
(3)开漏输出
(4)Push-pull open-drain output
拉电流与灌电流
(1)拉电流:GPIO输出电流,The direction of current flows outward from the pin
(2)灌电流:GPIO输入电流,The current direction flows from the outgoing pin
因此,IOThe port should output low level as much as possible,灌电流,因为IOThe port has limited ability to pull current,When the source current is too large,IO驱动能力不足
TTLSchottky triggers:将模拟信号转换为数字信号
上下拉电阻:acts as a clamp,There is an exact level when the pin is floating
推挽与开漏
(1)推挽:The two transistors are connected in push-pull mode(串联),可以输出高、低电平
- 输出为1时,T1导通,T2截止,输出高电平
- 输出为0时,T2导通,T1截止,输出低电平
(2)开漏:MOSThe drain of the tube is open circuited,输出低电平 ,An external pull-up resistor is required to achieve a high level
- 输出为1时,MOS管截止,External pull-up resistor output high level
- 输出为0时,MOS管导通,输出为低电平
保护二极管:限流的作用,防止电流过大,pins are damaged
(二)GPIO模块寄存器
1.控制寄存器:配置GPIO工作模式
(1)时钟配置
(2)工作模式配置
- 输入/输出模式
- Enter the drop-down configuration
- 输入中断配置
2.数据寄存器:输入/Output data buffer
(1)输入数据寄存器(只读)
(2)输出数据寄存器
3.Function multiplexing register:Configure the corresponding multiplexing mode according to the pins of the peripherals used
(三)GPIO配置流程
1.Select the appropriate pin according to the desired function
(1)端口选择
(2)引脚选择
2.Configure the corresponding working mode of the pin according to the desired function
(1)输入/输出模式/功能复用
(2)输入中断,Pin-related interrupts need to be configured
(四)编程
1.寄存器版本
#include "msp.h"
#include "driverlib.h"
int main()
{
WDT_A->CTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD;
//GPIO为普通IO模式
P1SEL0 &= ~BIT0;
P1SEL1 &= ~BIT0;
//GPIO为输出模式
P1DIR |= BIT0;
//IO输出为1
P1OUT |= BIT0;
while(1);
return 0;
}
2.库函数版本
#include "msp.h"
#include "driverlib.h"
int main()
{
WDT_A_holdTimer();
//GPIO为输出模式
GPIO_setAsOutputPin(GPIO_PORT_P1,GPIO_PIN0);
//IO输出为1
GPIO_setOutputHighOnPin(GPIO_PORT_P1,GPIO_PIN0);
while(1);
return 0;
}
边栏推荐
- [N1CTF 2018]eating_cms
- Golang第一章:入门
- CAS:1260586-88-6_生物素-C5-叠氮_Biotin-C5-Azide
- Cross-end development technical reserve record
- CAS: 773888-45-2_BIOTIN ALKYNE_生物素-炔基
- 472. Concatenated Words
- 113. Teach a Man how to fish - How to query the documentation and technical implementation details of any SAP UI5 control property by yourself
- Codeup刷题笔记-简单模拟
- 全球观之地理部分
- Codeup brushing notes - simple simulation
猜你喜欢
随机推荐
E-commerce data warehouse ODS layer-----log data loading
如何基于WPF写一款数据库文档管理工具(二)
上课笔记(6)(1)——#629. 表达式括号匹配(stack)
IDaaS 是什么?一文说清它的价值
图的基础概念
CAS:1260586-88-6_Biotin-C5-Azide_Biotin-C5-Azide
FVCOM三维水动力、水交换、溢油物质扩散及输运数值模拟丨FVCOM模型流域、海洋水环境数值模拟方法
[kali-vulnerability exploitation] (3.2) Metasploit basics (on): basic knowledge
关于Yii2批量更新的操作
斩获双奖|易知微荣获“2021中国数字孪生解决方案优秀供应商”“中国智能制造优秀推荐产品”双奖项!
FVCOM 3D Numerical Simulation of Hydrodynamics, Water Exchange, Dispersion and Transport of Oil Spills丨FVCOM Model Watershed, Numerical Simulation Method of Marine Water Environment
【bug】汇总Elipse项目中代码中文乱码解决方法!
Kubernetes入门到精通-Operator 模式
决策树、GBDT、XGBOOST树的可视化
noip初赛
Teach a Man How to Fish - How to Query the Properties of Any SAP UI5 Control by Yourself Documentation and Technical Implementation Details Demo
Data_web(八)mysql增量同步到mongodb
2022年全国职业院校技能大赛网络安全 B模块 任务十windows操作系统渗透测试 国赛原题
如何设计 DAO 的 PoW 评判标准 并平衡不可能三角
[N1CTF 2018]eating_cms