当前位置:网站首页>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;
}
边栏推荐
- 软件测试人员必备的60个测试工具清单,建议收藏一波~
- 上课笔记(6)(1)——#629. 表达式括号匹配(stack)
- [3D检测系列-PV-RCNN] PV-RCNN论文详解、PV-RCNN代码复现、包含官网PV-RCNN预训练权重及报错问题
- 网络基础学习系列四(网络层,数据链路层和一些其他重要协议或技术)
- Internet user account information management regulations come into effect today: must crack down on account trading and gray products
- 如何设计 DAO 的 PoW 评判标准 并平衡不可能三角
- Makefile
- HCIP第十四天
- 聚焦开源与联合共创|麒麟软件出席开源峰会欧拉分论坛
- 2019年10月SQL注入的两倍
猜你喜欢

Teach a Man How to Fish - How to Query the Properties of Any SAP UI5 Control by Yourself Documentation and Technical Implementation Details Demo

Gains double award | know micro easily won the "2021 China digital twin solution suppliers in excellence" "made in China's smart excellent recommended products" double award!

易基因:植物宏病毒组研究:植物病毒的进化与生态 | 顶刊综述

CAS:1260586-88-6_生物素-C5-叠氮_Biotin-C5-Azide

《强化学习周刊》第56期:GraphIRL、REDEEMER & 眼科强化学习的潜在研究

gtk实现图片旋转

今晚直播 | 8.2-8.4 与你聊聊开源与就业那些事!

嵌入式系统:GPIO

测试2年6.5K,每天“911”,我的心酸经历只有我自己知道···

Bytebase数据库 Schema 变更管理工具
随机推荐
2019年10月SQL注入的两倍
21天打卡挑战学习MySQL—Day第一周 第一篇
2022的七夕,奉上7个精美的表白代码,同时教大家快速改源码自用
CAS:122567-66-2_DSPE-Biotin_DSPE-Biotin
Codeup brushing notes - simple simulation
线上服务器老是卡,该如何优化?
如何设计 DAO 的 PoW 评判标准 并平衡不可能三角
Golang第二章:程序结构
现网设备兼容SRv6网络演进
[b01lers2020]Life on Mars
Optimize the query (work in progress)
优化查询(工作中)
目标检测的国内外研究现状
Data_web(八)mysql增量同步到mongodb
[kali-vulnerability exploitation] (3.2) Metasploit basics (on): basic knowledge
电商秒杀系统
Causes of Mysql Disk Holes and Several Ways to Rebuild Tables
决策树、GBDT、XGBOOST树的可视化
【Unity3D】Tank对战
Shell编程的条件语句