#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit duan=P2^0;
sbit wei=P2^1;
uchar xdata *posport=0xff20;
uchar xdata *dataport=0xff21;
uchar xdata *jianport=0xff22;
uchar xdata *conport=0xff23;
unsigned long int i;
uchar j,aa=0,bb=0,cc=0,dd=0,ee=0,ff=0;
void display(uchar liu,uchar wu,uchar si,uchar san,uchar er,uchar yi);
unsigned char code tab[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
unsigned char code lab[6]={0x20,0x10,0x08,0x04,0x02,0x01};
void init8255(void)
{
*conport=0x81;
}
void Diss8255(void)
{
for(j=0;j<6;j++)
{
if(aa==10)
{
aa=0;
bb++;
if(bb==6)
{
bb=0;
cc++;
if(cc==10)
{
cc=0;
dd++;
if(dd==6)
{
dd=0;
ee++;
if(ee==10)
{
ee=0;
ff++;
if(ff==2&&ee==4)
{aa=0,bb=0,cc=0,
dd=0,ee=0,ff=0;
}
}
}
}
}
}
}
}
void init(void)
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
}
void display(uchar liu,uchar wu,uchar si,uchar san,uchar er,uchar yi)
{
*dataport=tab[yi];
*posport=lab[0];
*dataport=tab[er];
*posport=lab[1];
*dataport=tab[san];
*posport=lab[2];
*dataport=tab[si];
*posport=lab[3];
*dataport=tab[wu];
*posport=lab[4];
*dataport=tab[liu];
*posport=lab[5];
}
void main(void)
{
init();
i=0;
init8255();
if(i==20)
{
i=0;
while(1)
{
Diss8255();
display(ff,ee,dd,cc,bb,aa);
aa++;
}
}
}void timer0() interrupt 1 using 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
i++;
}