当前位置:网站首页>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;
}
边栏推荐
- 易基因:植物宏病毒组研究:植物病毒的进化与生态 | 顶刊综述
- VIM操作
- Conditional Statements for Shell Programming
- FVCOM三维水动力、水交换、溢油物质扩散及输运数值模拟丨FVCOM模型流域、海洋水环境数值模拟方法
- 1 秒完成授权,Authing 全新上线一键登录功能
- 21天打卡挑战学习MySQL——《MySQL工具的使用》第一周 第二篇
- Soft exam system analysts note experience sharing: theory of protracted war
- 上课笔记(6)(1)——#629. 表达式括号匹配(stack)
- 21天打卡挑战学习MySQL——《Window下安装MySql》第一周 第三篇
- 关于Yii2批量更新的操作
猜你喜欢
Teach a Man How to Fish - How to Query the Properties of Any SAP UI5 Control by Yourself Documentation and Technical Implementation Details Demo
投资性大于游戏性 NFT游戏到底是不是门好生意
CAS:908007-17-0_Biotin-azide _生物素叠氮化物
LyScript 实现应用层钩子扫描器
for循环练习题
嵌入式开发:嵌入式基础——代码和数据空间揭秘
三年黑盒测试工程师对嵌入式软件测试的理解
七夕快乐!
封装、包、访问权限修饰符、static变量
目标检测技术研究现状及发展趋势
随机推荐
授人以渔 - 如何自行查询任意 SAP UI5 控件属性的文档和技术实现细节试读版
October 2019 Twice SQL Injection
东西向和南北向通信的统一
488. Zuma Game
CAS:908007-17-0_Biotin-azide_Biotin azide
超级实用网站+公众号合集
start with connect by implements recursive query
start with connect by 实现递归查询
noip初赛
shell编程基础
Conditional Statements for Shell Programming
2019年10月SQL注入的两倍
『百日百题 · 基础篇』备战面试,坚持刷题 第四话——循环语句!
软件测试人员必备的60个测试工具清单,建议收藏一波~
HCIP第十三天
目标检测的国内外研究现状
CAS: 773888-45-2_BIOTIN ALKYNE_Biotin-alkynyl
一文带你了解软件测试是干什么的?薪资高不高?0基础怎么学?
函数,递归以及dom简单操作
如何基于WPF写一款数据库文档管理工具(二)