MSP432学习笔记2——GPIO输入输出

29 篇文章 19 订阅 ¥59.90 ¥99.00
这篇博客介绍了MSP432单片机的GPIO输入输出功能,通过实践操作连接矩阵键盘和5050全彩RGB七彩LED流水灯模块,探讨了GPIO配置函数、引脚功能,并提供了硬件连接和KEIL编程的详细过程。在实践中遇到LED模块无法启用的问题,分析可能的原因并提出解决方案。
摘要由CSDN通过智能技术生成

今日继续更新我的MSP432速通笔记

新的硬件芯片到手,脑子是空白的,板子是漆黑的,诺想要缓解这份尴尬,便来点灯吧!

今日主要速通MSP432的GPIO输入输出功能,目标是连接矩阵键盘与LED流水灯模块

到MSP432P401R开发板上进行练习。

文章附上原理图与代码

目录

​编辑

基础知识学习:

1.模块介绍以及原理

1.矩阵键盘

2.5050全彩RGB七彩LED流水灯模块

2.MSP432基础GPIO输入输出配置函数

3.MSP432引脚功能分类与学习

一、端口P1、P2、P3、P4、P5、P6

二、端口P7、P8、P9、P10、PJ

实践操作练习:

硬件电路连接: 

矩阵键盘接法:

LED接法:

连接后的效果图:

3.KEIL编程:

后来下载后测量引脚示波与电压发现LED流水灯模块没法启用:


基础知识学习:

1.模块介绍以及原理

1.矩阵键盘

<
MSP432 低功耗高性能并存10.1 Digital I/O Introduction The digital I/O features include: • Independently programmable individual I/Os • Any combination of input or output • Individually configurable interrupts for ports (available for certain ports only) • Independent input and output data registers • Individually configurable pullup or pulldown resistors • Wake-up capability from ultra-low power modes (available for certain ports only) • Individually configurable high drive I/Os (available for certain I/Os only) Devices within the family may have up to eleven digital I/O ports implemented (P1 to P10 and PJ). Most ports contain eight I/O lines; however, some ports may contain less (see the device-specific data sheet for ports available). Each I/O line is individually configurable for input or output direction, and each can be individually read or written. Each I/O line is individually configurable for pullup or pulldown resistors. Certain ports have interrupt and wake-up capability from ultra-low power modes (see device specific data sheet for ports with interrupt and wake-up capability). Each interrupt can be individually enabled and configured to provide an interrupt on a rising or falling edge of an input signal. All interrupts are fed into an encoded Interrupt Vector register, allowing the application to determine which sub-pin of a port has generated the event. Individual ports can be accessed as byte-wide ports or can be combined into half-word-wide ports. Port pairs P1 and P2, P3 and P4, P5 and P6, P7 and P8, and so on, are associated with the names PA, PB, PC, PD, and so on, respectively. All port registers are handled in this manner with this naming convention. The main exception are the interrupt vector registers, for example, interrupts for ports P1 and P2 must be handled through P1IV and P2IV, PAIV does not exist. When writing to port PA with half-word operations, all 16 bits are written to the port. When writing to the lower byte of port PA using byte operations, the upper byte remains unchanged. Similarly, writing to the upper byte of port PA using byte instructions leaves the lower byte unchanged. When writing to a port that contains less than the maximum number of bits possible, the unused bits are don't care. Ports PB, PC, PD, PE, and PF behave similarly.
MSP432GPIO库提供了一系列函数用于配置和操作MSP432微控制器的GPIO引脚。下面是一些常用的MSP432GPIO函数: 1. `GPIO_setAsInputPin(selectedPort, selectedPins)`:将指定的GPIO引脚配置为输入模式。 2. `GPIO_setAsOutputPin(selectedPort, selectedPins)`:将指定的GPIO引脚配置为输出模式。 3. `GPIO_setAsPeripheralModuleFunctionInputPin(selectedPort, selectedPins, selectedModule)`:将指定的GPIO引脚配置为特定外设模块的输入引脚。 4. `GPIO_setAsPeripheralModuleFunctionOutputPin(selectedPort, selectedPins, selectedModule)`:将指定的GPIO引脚配置为特定外设模块的输出引脚。 5. `GPIO_setOutputHighOnPin(selectedPort, selectedPins)`:将指定的GPIO引脚输出高电平。 6. `GPIO_setOutputLowOnPin(selectedPort, selectedPins)`:将指定的GPIO引脚输出低电平。 7. `GPIO_toggleOutputOnPin(selectedPort, selectedPins)`:反转指定的GPIO引脚输出电平。 8. `GPIO_getInputPinValue(selectedPort, selectedPins)`:获取指定的GPIO引脚输入电平。 这些函数中,`selectedPort`表示选择的GPIO端口号,`selectedPins`表示选择的引脚号,可以通过逻辑或运算符(`|`)选择多个引脚。`selectedModule`表示选择的外设模块号。 以下是一个使用MSP432GPIO函数的示例: ```c #include <ti/devices/msp432p4xx/driverlib/driverlib.h> int main(void) { // 初始化MSP432启动代码 // 配置P1.0引脚为输出模式 GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0); // 设置P1.0引脚输出高电平 GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0); // 延时一段时间 // 设置P1.0引脚输出低电平 GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0); // 其他代码 return 0; } ``` 在上述示例中,我们将P1.0引脚配置为输出模式,并在延时后将其输出高电平和低电平。你可以根据需要使用不同的函数来配置和操作GPIO引脚。
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

NULL指向我

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值