#include "ioCC2530.h"
#define uchar unsigned char
#define led1 P1_0
#define led2 P1_1
#define led3 P1_4
#define led4 P0_1
void initled(void)
{
P1SEL &=~0x13;
P1DIR |= 0x13;
P0SEL &=~0x02;
P0DIR |= 0x02;
}
void init(void)
{
IEN0|=0x80; //开总中断
IEN1|=0x20; //开p0中断
P0IEN |=0x20; //注意还要打开 P0对应位的中断 否则不会引起中断
PICTL|=0x01; //选择高四位 下降沿置1
}
void main(void)
{
init();
initled();
P0IFG = 0x00;
led1=0;
led2=0;
led3=0;
led4=0;
while(1)
{}
}
#pragma vector=P0INT_VECTOR
__interrupt void P0_IRQ(void)
{
if(P0IFG!=0x00)//初始化时标志位就是0
{
if(led1==1)
{
led1=0;
}
else
{
led1=1;
}
P0IFG=0x00;
IRCON&=~0x20;
}
}