This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
器件型号:MSP432P401R
工具/软件:Code Composer Studio
您好!
我目前正在使用 MSP432401R、我想知道如何在 code composer studio 中提供输入。 之前、我一直在使用 Energia 进行编码、在此代码中、我可以 根据我的要求将引脚声明为输入或输出、但在 CCS 中声明输入和输出会令人困惑。 如果您可以澄清这一点、并在可能的情况下提供一个示例、那将会有所帮助。
谢谢。
只需使用 MSP432 GPIO 示例。 使用 DriverLib:
int main (void) { volatile uint32_t ii; //暂停看门狗*/ MAP_WDT_A_HOLDTimer (); //将 P1.0配置为输出*/ MAP_GPIO_setAsOutputPin (GPIO_PORT_P1、GPIO_PIN0); while (1) { // delay Loop * for (i=0;GPIO_PORT_INP1 )}+(gp2+) }<gpio_IN5000
谢谢您 Keith。 我将查看这些文档。 同时、我编写了一个程序、用于在按下按钮时点亮 LED、而在松开按钮时 LED 应熄灭。
#include
/**
* main.c
*
void button1_init (void){
P1->SEL0 &=~0x02;
P1->SEL1 &=~0x02;
P1->DIR &=~0x02;
}
void LED_ouit (void){
P1->SEL0 &=~0x01;
P1->SEL1 &=~0x01;
P1->DIR |= 0x01;
}
void LED_exe (uint8_t new){
/*uint8_t old;
OLD = P1->OUT;
OLD = OLD&(~0x01);
新建=新建|旧;*/
P1->OUT =新;
}
uint8_t button_exe (void)
{
uint8_t 按钮;
按钮= P1->IN;
按钮=按钮&0x02;
返回按钮;
}
void main (void)
{
uint8_t 数据;
int i;
WDT_A->CTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD;//停止看门狗计时器
Button1_init();
LED_OUIT();
while (1){
for (i=1;i<500;i++){
}
数据= button_exe();
if (data==2){
LED_exe (1);
}
否则{
LED_exe (0);
}
}
}
但不幸的是,当我执行该程序时,LED 指示灯亮起,不会按输入按钮。 请您仔细查看代码、并告诉我可能会犯什么错误。
谢谢。