#include "reg51.h"
typedef unsigned int u16;
typedef unsigned char u8;
int shi=0,fen=0,s0=0,s1=0,bittime=0,bitdisplay=0;
unsigned char Tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
//P2=Tab[s1];P3=0Xef;
void delay(u16 i)
{
while(i--);
}
void timer0(void) interrupt 1 using 0
{
TH0=(65536-50000)/256;TL0=(65536-50000)/256;
switch(bitdisplay)
{
case 0:P2=Tab[s0];P3=0Xdf;break;
case 1:P2=Tab[s1];P3=0Xef;break;
}
bitdisplay++;
bittime++;
if(bitdisplay==2){bitdisplay=0;}
}
void main(void)
{
TMOD=0X01;TH0=(65536-50000)/256;TL0=(65536-50000)/256;
EA=1;ET0=1;TR0=1;
while(1)
{
if(bittime==20)
{
bittime=0;
s0++;
}
if(s0==10)
{
s0=0;
s1++;
}
}
}
|