怎么没定时1s
在开发板上 操作的 12MHZ晶振#include<reg52.h>
#define uint unsigned int
#define uchar unsigned int
uchar aa,bai,shi,ge;
uint temp;
void delay(uint z);
void display(uchar bai,uchar shi,uchar ge);
void init();
uchar code table[]={0xc0,0xf9,
0xA4,0xB0,
0x99,0x92,
0x82,0xf8,
0x80,0x90};
void main()
{init();
while(1)
{if(aa==20)
{aa=0;
temp--;
if(temp==0)
{temp=999;}
bai=temp/100;
shi=temp%100/10;
ge=temp%10;}
display(bai,shi,ge);
}
}
void init() //初始化子程序
{aa=0;
temp=999;
TMOD=0X01; //选TO在方式1
TH0=(65536-50000)/256; //装初值
TH0=(65536-50000)%256;
EA=1; //开总中断
ET0=1; //允许T0溢出中断
TR0=1;} //开启TIMER0
void timer0() interrupt 1 //定时中断服务子程序 1
{TH0=(65536-50000)/256;
TH0=(65536-50000)%256;
aa++;}
void display(uchar bai,uchar shi,uchar ge)
{P3=0XFE;
P0=table[bai];
delay(1);
P3=0XFD;
P0=table[shi];
delay(1);
P3=0XFB;
P0=table[ge];
delay(1);
}
void delay(uint z) //延时子程序
{uint x,y;
for(x=z;x>0;x--)
for(y=180;y>0;y--);
}