#include <reg52.h>
sbit duan=P2^6;
sbit wei=P2^7;
bit flag1,flag;
unsigned char code duanma[]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char code Weima[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf};
unsigned char temp[6];
void display()
{
static unsigned char i;
duan=1;
P0=0;
duan=0;
wei=1;
P0=Weima[i];
wei=0;
duan=1;
P0=temp[i];
duan=0;
i++;
if(i==6)
i=0;
}
void init_time0()
{
TMOD=0X01;
TH0=(65536-2000)/256;
TL0=(65536-2000)%256;
EA=1;
ET0=1;
TR0=1;
}
void init_time() interrupt 1
{
static unsigned int num;
TH0=(65536-3000)/256;
TL0=(65536-3000)%256;
display();
num++;
if(num==200)
{
num=0;
flag=1;
}
}
void main()
{
static unsigned char flag3=0;
char shu;
init_time0();
shu=5;
if(shu>=10)
temp[0]=duanma[shu/10];
else
temp[0]=0;
temp[1]=duanma[shu%10];
while(1)
{
if(flag)
{
flag=0;
shu--;
if(shu<=0)
flag3++;
if(flag3==1)
shu=5;
if(flag3==2)
shu=35;
if(flag3==3)
{
shu=30;
flag3=0;
}
if(shu>=10)
temp[0]=duanma[shu/10];
else
temp[0]=0;
temp[1]=duanma[shu%10];
}
}
}请问下为什么数码管计数会突然停止 |