#include<reg52.h>
unsigned int i=0,num=0,time=60;
unsigned char ge,shi;
unsigned int code table[10]={0x3f,0xXXX,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void delay(unsigned int);
void display();
main()
{TMOD=0X01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
EX0=1;
IT0=1;
while(1)
{while(time!=5)
{ P1=0XF3;
if(num==20)
{time--;
num=0;
}
display();
}
while(time!=2)
{if(num==10)
P1=0XF7;
if(num==20)
{P1=0XF3;
num=0;
time--;
}
display();
}
while(time!=0)
{ P1=0XF5;
if(num==20)
{num=0;
time--;
}
display();
}
time=30;
while(time!=5)
{P1=0XDE;
if(num==20)
{num=0;
time--;
}
display();
}
while(time!=2)
{if(num==10)
P1=0XFE;
if(num==20)
{P1=0XDE;
num=0;
time--;
}
display();
}
while(time!=0)
{P1=0XEE;
if(num==20)
{num=0;
time--;
}
display();
}
time=60;
}
}
void display()
{ shi=time/10;
ge=time%10;
P2=0XFE;
P0=table[ge];
delay(5);
P2=0XFD;
P0=table[shi];
delay(5);
P2=0XFB;
P0=table[ge];
delay(5);
P2=0XF7;
P0=table[shi];
delay(5);
}
void delay(unsigned int z)
{unsigned int x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void exter0() interrupt 0
{ num=0;
time=20;/*数码管计时显示*/
P1=0XF6;
While(time!=0)
{
If(num=20)
{num=0;
time--}
disply();}}
void time0() interrupt 1
{num++;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
}