程序写完没什么错,下载到板子上只亮了前三位765,后三位是000
我的程序是想765432倒计时到765398停止
下面是程序
#include"reg52.h"
#define uint unsigned int
#define uchar unsigned char
uchar code tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
sbit LES1=P2^2;
sbit LES2=P2^3;
sbit LES3=P2^4;
uchar bai,shi,ge,temp;
uint shu;
void delay(uchar x)
{
uchar i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void timeChuShi()
{
shu=432;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
}
void display(uchar aa,uchar bb,uchar cc,uchar bai,uchar shi,uchar ge)
{
LES1=0;
LES2=0;
LES3=0;
P0=tab[ge];
delay(1);
LES1=1;
LES2=0;
LES3=0;
P0=tab[shi];
delay(1);
LES1=0;
LES2=1;
LES3=0;
P0=tab[bai];
delay(1);
LES1=1;
LES2=1;
LES3=0;
P0=tab[cc];
delay(1);
LES1=0;
LES2=0;
LES3=1;
P0=tab[bb];
delay(1);
LES1=1;
LES2=0;
LES3=1;
P0=tab[aa];
delay(1);
}
void main()
{
timeChuShi();
while(1)
{
display(7,6,5,bai,shi,ge);
}
}
void timer_0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
temp=0;
temp++;
if(temp==2)
{
temp=0;
shu--;
bai=shu/100;
shi=shu%100/10;
ge=shu%10;
if(shu==398)
{
TR0=0;
}
}
}
我的程序是想765432倒计时到765398停止
下面是程序
#include"reg52.h"
#define uint unsigned int
#define uchar unsigned char
uchar code tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
sbit LES1=P2^2;
sbit LES2=P2^3;
sbit LES3=P2^4;
uchar bai,shi,ge,temp;
uint shu;
void delay(uchar x)
{
uchar i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);
}
void timeChuShi()
{
shu=432;
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
}
void display(uchar aa,uchar bb,uchar cc,uchar bai,uchar shi,uchar ge)
{
LES1=0;
LES2=0;
LES3=0;
P0=tab[ge];
delay(1);
LES1=1;
LES2=0;
LES3=0;
P0=tab[shi];
delay(1);
LES1=0;
LES2=1;
LES3=0;
P0=tab[bai];
delay(1);
LES1=1;
LES2=1;
LES3=0;
P0=tab[cc];
delay(1);
LES1=0;
LES2=0;
LES3=1;
P0=tab[bb];
delay(1);
LES1=1;
LES2=0;
LES3=1;
P0=tab[aa];
delay(1);
}
void main()
{
timeChuShi();
while(1)
{
display(7,6,5,bai,shi,ge);
}
}
void timer_0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
temp=0;
temp++;
if(temp==2)
{
temp=0;
shu--;
bai=shu/100;
shi=shu%100/10;
ge=shu%10;
if(shu==398)
{
TR0=0;
}
}
}