#include <reg51.h>
unsigned char code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char code digittab[3][8]=
{
{0x40,0x40,0x44,0x44,0x44,0x44,0x40,0x00},
{0x00,0x3c,0x42,0x81,0x81,0x81,0x42,0x3c},
{0x00,0x18,0x24,0x42,0x81,0x42,0x24,0x18},
};
unsigned int timecount;
unsigned char cnta;
unsigned char cntb;
void main(void)
{
TMOD=0x01;
TH0=(65536-5000)/256;
TL0=(65536-5000)%256;
EA=1;
TR0=1;
ET0=1;
while(1);
}
void t0(void) interrupt 1 using 0
{
TH0=(65536-5000)/256;
TL0=(65536-5000)%256;
P2=tab[cnta];
P1=digittab[cntb][cnta];
cnta++;
if(cnta==8) cnta=0;
timecount++;
if(timecount==200)
{
timecount=0;
cntb++;
if(cntb==3) cntb=0;
}
}
|