当前位置:网站首页>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;
}
边栏推荐
- 封装、包、访问权限修饰符、static变量
- 466. Count The Repetitions
- 如何设计 DAO 的 PoW 评判标准 并平衡不可能三角
- CAS:1620523-64-9_Azide-SS-biotin_生物素-二硫-叠氮
- CAS: 773888-45-2_BIOTIN ALKYNE_生物素-炔基
- 超级实用网站+公众号合集
- CAS: 1192802-98-4 _uv cracking of biotin - PEG2 - azide
- 382. Linked List Random Node
- 2022年全国职业院校技能大赛网络安全 B模块 B-1任务一:主机发现与信息收集 国赛原题
- 中国企业构建边缘计算解决方案的最佳实践
猜你喜欢
随机推荐
投资性大于游戏性 NFT游戏到底是不是门好生意
2022-08-03 oracle执行慢SQL-Q17对比
一些思考:腾讯股价为何持续都低
Pay from 0 to 1
如何设计 DAO 的 PoW 评判标准 并平衡不可能三角
趣链的产品构架
October 2019 Twice SQL Injection
从0到1看支付
466. Count The Repetitions
Data_web(八)mysql增量同步到mongodb
nxp官方uboot移植到野火开发板PRO(无任何代码逻辑的修改)
XSS online shooting range---haozi
函数,递归以及dom简单操作
Bytebase数据库 Schema 变更管理工具
nxp官方uboot移植到野火开发板PRO(修改LCD部分和网络部分)
UVa 10003 - Cutting Sticks(白书,区间DP)
Security Fundamentals 8 --- XSS
[kali-vulnerability scanning] (2.1) Nessus lifts IP restrictions, scans quickly without results, and plugins are deleted (middle)
UVa 437 - The Tower of Babylon(白书)
嵌入式系统:概述









