#include <REGX52.H>
#include "Timer0.h"
#include "Key.h"
#include <INTRINS.H>
unsigned char KeyNum,LEDMode;
void main()
{
P2=0xFE;
Timer0_Init();
while(1)
{
KeyNum=Key();
if(KeyNum)
{
if(KeyNum==1) P2_1=~P2_1;
{
LEDMode++;
if(LEDMode>=2) LEDMode=0;
}
}
}
}
void Timer0_Routine() interrupt 1 //中断函数
{
static unsigned int T0Count; //静态局部变量
TH0=64535/256;//设初始高位数值
TL0=64535&256;//设初始低位数值
T0Count++;
if(T0Count>=500)
{
T0Count=0;
if(LEDMode==0)
P2=_crol_(P2,1);
if(LEDMode==1)
P2=_cror_(P2,1);
}
}
void Delay(unsigned int xms) //@12.000MHz
{
unsigned char i, j;
while(xms--)
{
i = 2;
j = 239;
do
{
while (--j);
} while (--i);
}
}
#include <REGX52.H>
#include "Delay.h"
/**
* &#