#include"reg52.h"
#include"intrins.h"
#define uchar unsigned char
sbit S3=P2^4;
sbit S4=P2^5;
sbit S5=P2^6;
sbit S6=P2^7;
uchar a,b,e=0x01,time;
int num;
uchar code TAB[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar c[3]={0xff,0xff,0xff};
void delayms()
{
for(a=10;a>0;a--)
for(b=124;b>0;b--);
}
void delayms2()
{
for(a=5;a>0;a--)
for(b=124;b>0;b--);
}
void anjian()
{
if(S3==0)
{
delayms();
if(S3==0)
{
num++;
num=(num>=1000)?0:num;
while(!S3);
}
}
if(S4==0)
{
delayms();
if(S4==0)
{
num=(num==0)?1000:num;
num--;
while(!S4);
}
}
if(S5==0)
{
delayms();
if(S5==0)
{
num=0;
while(!S5);
}
}
if(S6==0)
{
delayms();
if(S6==0)
{
TR0=~TR0;
}
while(!S6);
}
c[0]=TAB[num/100];
c[1]=TAB[(num%100)/10];
c[2]=TAB[(num%100)%10];
}
void xianshi()
{
P0=0xff;
if(e==8) e=0x01;
P2=~e;
P0=c[e/2];
e=_crol_(e,1);
delayms2();
}
main()
{
IE=0x8a;
TMOD=0x21;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR0 = 0;
TH1=6;
TL1=6;
TR1=1;
while(1) ;
}
void T0_() interrupt 1
{
TR0=0;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
if(++time==20)
{
time=0;
num++;
num=(num>=1000)?0:num;
}
c[0]=TAB[num/100];
c[1]=TAB[(num%100)/10];
c[2]=TAB[(num%100)%10];
TR0=1;
}
void T1_() interrupt 3
{
TR1=0;
anjian();
xianshi();
TR1=1;
}
|