#include
#define uchar unsigned char
uchar code ledtab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//0-9
unsigned char scanled;
unsigned char disdat[8];
void dischg()
{
disdat[0]=4;
disdat[1]=1;
disdat[2]=1;
disdat[3]=1;
disdat[4]=6;
disdat[5]=1;
disdat[6]=0;
disdat[7]=2;
}
void t1isr() interrupt 3 //显示
{
TH1=0xec;
TL1=0x78;
switch(scanled)
{
case 0:
P2=0x01;
P0=~ledtab[disdat[7]];
break;
case 1:
P2=0x02;
P0=~ledtab[disdat[6]];
break;
case 2:
P2=0x04;
P0=~ledtab[disdat[5]];
break;
case 3:
P2=0x08;
P0=~ledtab[disdat[4]];
break;
case 4:
P2=0x10;
P0=~ledtab[disdat[3]];
break;
case 5:
P2=0x20;
P0=~ledtab[disdat[2]];
break;
case 6:
P2=0x40;
P0=~ledtab[disdat[1]];
break;
case 7:
P2=0x80;
P0=~ledtab[disdat[0]];
break;
default:break;
}
scanled++;
scanled%=8;
}
main()
{
TMOD=0x10;
TH1=0xec;
TL1=0x78;
EA=1;
TR1=1;
ET1=1;
scanled=0;
dischg();
while(1);
}