这个我仿真过了 是有用的,,,是从00开始显示 到了99会从新开始从00开始加
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code disp[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar code bit_tab[]={0xfe,0xfd};
uchar disp_buf[2];
uchar shu;
uchar count;
void delay(uchar x)
{
uchar i,j;
for(i=0;i<x;i++)
for(j=0;j<120;j++);
}
void conv(uchar flag)
{
disp_buf[0]=flag/10;
disp_buf[1]=flag%10;
}
void display()
{
uchar tem,wei;
P2=bit_tab[wei];
tem=disp_buf[wei];
P0=disp[tem];
wei++;
if(wei==2)
wei=0;
}
void time0(void) interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
if(++count==40)
{
count=0;
shu++;
if(shu==99)
shu=0;
}
}
void time1(void) interrupt 3
{
TH1=(65536-5000)/256;
TL1=(65536-5000)%256;
display();
}
void init()
{
TMOD=0x11;
EA=1;
ET0=1;
ET1=1;
TR1=1;
TR0=1;
}
main()
{
init();
while(1)
{
conv(shu);
}
}