#include"msp430.h"
#define uint unsigned int
int main(void)
{
void delay(uint);
/*管脚配置P1.0为灯输出模式,P1.1为键盘中断*/
P1DIR |= (BIT0+(~BIT1));
P1REN |= (BIT0+BIT1);
P1OUT |= ((~BIT0)+BIT1); //LED 最初不亮
/*中段寄存器配置*/
//开中断
P1IFG &= (~BIT1);
P1IES |= BIT1;//下降沿触发
P1IE |= BIT1;
_EINT();//开总中断
while(1);
}
void delay(uint ms)
{
uint i,j;
for(i=ms;i>0;i++)
for(j=110;j>0;j--);
}
#pragma vector = PORT1_VECTOR__interrupt void Key_interrput(void)
{
delay(50);
if((P1IFG&BIT1)!=0)
{
// if((P1OUT&BIT0)==0)
// else P1OUT &= (~BIT0);
P1OUT |= BIT0;
P1IFG &=(~BIT1);
P1OUT |= BIT1;
}
} |