#include
#define uchar unsigned char
#define uint unsigned int
sbit dula=P2^6;
sbit wela=P2^7;
uchar a,num=5432,i,j;
uchar code x[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x67};
void displaynum();
void delays();
void main()
{ EA=1;
TMOD=0x11;
ET0=1;
ET1=1;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
TR0=1;
TR1=1;
while(1)
{ if(a==2)
{ a=0;
displaynum();
num--;
delays(); @@@@ 另外 此时delays函数的时间是不是不能比定时器间隔的时间短??
if(num==4987)
TR1=0;}
}
}
void time1() interrupt 3
{ TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
a++;
}
void displaynum()
{ q=num/1000;
b=num%1000/100;
s=num%1000%100/10;
g=num%1000%100%10;
dula=1;
P0=x[g];
dula=0;
wela=1;
P0=0xdf;
wela=0;
dula=1;
P0=x;
dula=0;
wela=1;
P0=0xef;
wela=0;
dula=1;
P0=x;
dula=0;
wela=1;
P0=0xf7;
wela=0;
dula=1;
P0=x[q];
dula=0;
wela=1;
P0=0xfb;
wela=0;
}
void delays()
{
for(i=0;i<=50;i++)
for(j=110;j>=0;j--);
}
这个程序哪里不对么? 为啥工作不了?啊
[ 本帖最后由 小白是我 于 2013-5-14 23:24 编辑 ] |