#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
uchar aa,numdu,shu,s,h2,h1,m1,m2;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void display(uchar ,uchar ,uchar,uchar);
void main()
{ shu=1;
numdu=0;
P2=0x0f;
s=0;
aa=0;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{
display ( h2,h1,m2, m1);
}
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
aa++;
if(aa==20)
{
aa=0;
s=s+1;
if(s==60)
{ s=0;
h2=shu*0;
h1=shu*0;
m2=shu*0;
m1=shu;
shu++ ;
}
}
}
void display(uchar m1,uchar m2,uchar h1,uchar h2)
{
P0=table[m1];
P0=table[m2];
P0=table[h1];
P0=table[h2];
}
我想让四个数码管,前三个显示0最后一个从零到九,但就是显示不出,谁告诉我原因 |