嘎嘎嘎,刚好写过
60秒倒计时程序
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar temp,bai,shi,ge,num;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void delay(uint);
void main()
{
temp=60;
num=0;
P2=0x00;
TMOD=0x01;
TH0=(65536-45872)/256;
TL0=(65536-45872)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{
shi=temp/10;
ge=temp%10;
P0=table[shi];
P2=0x02;
delay(5);
P0=table[ge];
P2=0x01;
delay(5);
}
}
void T0_time()interrupt 1
{
TH0=(65536-45872)/256;
TL0=(65536-45872)%256;
num++;
if(num==40)
{
num=0;
temp--;
if(temp==0)
{
temp=60;
}
}
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
追问你的程序我编译过了试了,但不出现象,纠结死了!