#include "iocc2530.h"
#define LED1 P1_0
#define LED2 P1_1
#define LED3 P0_4
#define KEY1 P0_1
typedef unsigned int uint;
uint flag;
void InitLed()
{
P1DIR |=0X03;
P0DIR |=0X10;
LED1=0;
LED2=0;
LED3=0;
}
void InitKey()
{
P0IE=1;
P0IEN |=0x02;
PICTL |=0x01;
EA=1;
P0IFG=0;
}
void Delay(uint ms)
{
uint i,j;
for (i=0;i<ms;i++);
for (j=0;j<535;j++);
}
#pragma vector = P0INT_VECTOR
__interrupt void P0_ISR(void)
{
if((P0IFG & 0x02)>0)
{
Delay(10);
if((P0IFG & 0x02)>0)
flag=1;
}
P0IFG &=~ 0x02;
P0IF=0;
}
void main()
{
InitLed();
InitKey();
while(1)
{
if(flag==1)
{
LED3=!LED3;
Delay(200);
LED2=!LED2;
Delay(200);
LED1=!LED1;
Delay(200);
flag=0;
}
}
}
#define LED1 P1_0
#define LED2 P1_1
#define LED3 P0_4
#define KEY1 P0_1
typedef unsigned int uint;
uint flag;
void InitLed()
{
P1DIR |=0X03;
P0DIR |=0X10;
LED1=0;
LED2=0;
LED3=0;
}
void InitKey()
{
P0IE=1;
P0IEN |=0x02;
PICTL |=0x01;
EA=1;
P0IFG=0;
}
void Delay(uint ms)
{
uint i,j;
for (i=0;i<ms;i++);
for (j=0;j<535;j++);
}
#pragma vector = P0INT_VECTOR
__interrupt void P0_ISR(void)
{
if((P0IFG & 0x02)>0)
{
Delay(10);
if((P0IFG & 0x02)>0)
flag=1;
}
P0IFG &=~ 0x02;
P0IF=0;
}
void main()
{
InitLed();
InitKey();
while(1)
{
if(flag==1)
{
LED3=!LED3;
Delay(200);
LED2=!LED2;
Delay(200);
LED1=!LED1;
Delay(200);
flag=0;
}
}
}