#include<msp430x14x.h>
char key;
char temp;
int i;
void main()
{
WDTCTL=WDTPW+WDTHOLD;
P1IES=0XFF;
P1IE=0XFF;
P2DIR=0XFF;
P2OUT=0XFF;
_EINT();
while(1)
{
while(key&0x01)
{
P2OUT=0Xfe;
}
while(key&0x02)
{
P2OUT=0x00;
}
}
}
#pragma vector=PORT1_VECTOR
__interrupt void PORT1_ISR(void)
{
temp=P1IFG;
temp=temp&0x0f;
P1IFG=0x00;
switch(temp)
{
case 0x01:
key=0x01;
break;
case 0x02:
key=0x02;
break;
case 0x04:
key=0x04;
break;
case 0x08:
key=0x08;
break;
}
} |