当前位置:网站首页>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;
}
边栏推荐
- 基于支持向量机的网络⼊侵检测系统的全面调查和分类
- 2022年全国职业院校技能大赛网络安全 B模块 任务十windows操作系统渗透测试 国赛原题
- October 2019 Twice SQL Injection
- Security Fundamentals 8 --- XSS
- Makefile
- 【刷题篇】二叉树的右视图
- CAS: 1192802-98-4 _uv cracking of biotin - PEG2 - azide
- CAS:1797415-74-7_TAMRA-Azide-PEG-Biotin
- CAS:1797415-74-7_TAMRA-Azide-PEG-Biotin
- CAS:122567-66-2_DSPE-Biotin_DSPE-Biotin
猜你喜欢
随机推荐
mysql如何将表结构导出到excel
2022-08-02 mysql/stonedb slow SQL-Q18 - memory usage surge analysis
1 秒完成授权,Authing 全新上线一键登录功能
Optimize the query (work in progress)
488. Zuma Game
DO280管理和监控OpenShift平台--资源限制
[b01lers2020]Life on Mars
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 brushing notes - simple simulation
Cisco ike2 IPSec配置
2022的七夕,奉上7个精美的表白代码,同时教大家快速改源码自用
亿流量大考(2):开发一套高容错分布式系统
HCIP第十三天
Cisco ike2 IPSec configuration
数据一致性:双删为什么要延时?
【进阶自动化测试】一文1000教你如何用Postman做接口自动化测试
嵌入式系统:概述
Nacos配置文件管理、微服务获取Nacos配置文件
STP生成树
Shell编程的条件语句