下面是我从0到1000计数,可是为什么我记到6就错了呢,我是哪里错了啊,我是新手水平不高的
#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
uchar aa,unmp,qian,bai,shi,ge;
void dingshi();
void dealy(uint z);
void xs(uchar qian,uchar bai,uchar shi,uchar ge);
uchar code table[]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,
0x07,0x7f,0x6f};
void main()
{
dingshi();
while(1)
{
if(aa==20)
{
aa=0;
unmp++;
if(unmp==1000)
unmp=0;
qian=unmp/1000;
bai=unmp/100%10;
shi=unmp/10%10;
ge=unmp%10;
}
xs(qian,bai,shi,ge);
}
}
void dingshi()
{
EA=1;
ET0=1;
TMOD=0x01;
TR0=1;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
unmp=0;
}
void et0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
aa++;
}
void xs(uchar qian,uchar bai,uchar shi,uchar ge)
{
P1=table[qian];
P0=0xf7;
dealy(5);
P1=table[bai];
P0=0xfb;
dealy(5);
P1=table[shi];
P0=0xfd;
dealy(5);
P1=table[ge];
P0=0xfe;
dealy(5);
}
void dealy(uint z)
{
uint x,y;
for(x=200;x>0;x--)
for(y=z;y>0;y--);
}
此帖出自
小平头技术问答
{
TH0=(65536-45872)/256;
TH0=(65536-45872)%256;
num2++;
if(num2==2) 这里应该是 if(num2==20) 记到20是一秒
一周热门 更多>