急求高手看下这个程序,按照要求让数码管稳定显示数字变化,可是只有一位稳定变化,另一位闪烁变化。急求调试两天了,实在找不到问题所在
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
uint num;
uchar shi,fen,miao,s,g,shi,ge;
sbit du=P2^6;
sbit we=P2^7;
uchar table[]={
0x3F,0x06,0x5B,
0x4F,0x66,0x6D,
0x7D,0x07,0x7F,
0x6F,0x48//:
};
void delayms(uchar x)
{
uchar i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void timer()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
}
void displays(uchar shi,uchar ge)
{
we=1;P0=0x7f;we=0;
du=1;P0=table[shi];du=0;
P0=0xff;delayms(5);
we=1;P0=0xbf;we=0;
du=1;P0=table[ge];du=0;
P0=0xff;delayms(5);
}
void main()
{
timer();
while(1)
{
if(num==20)
{
num=0;
miao++;
if(miao==60)
{
miao=0;
}
s=miao%10;
g=miao/10;
displays(s,g);
}
}
}
void timer1() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
num++;
}
|