主要是我调试的时候,我的count要80才能是正常的一秒而不是20,还有就是main函数的if(time==60)
time=0;
shi=time/10;
ge=time%10;
能不能调到中断哪里啊??
#include
#define uchar unsigned char
#define GPIO_DIG P0 //¶ÎÑ¡
sbit a=P1^2;
sbit b=P1^3;//λѡ
unsigned char code DIG_CODE[] = {
0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,
0xc6,0xa1,0x86,0x8e};
//0¡¢1¡¢2¡¢3¡¢4¡¢5¡¢6¡¢7¡¢8¡¢9¡¢A¡¢b¡¢C¡¢d¡¢E¡¢FµÄÏÔʾÂë
uchar time=0,count=0;
uchar ge,shi;
void delay(unsigned int i);
void display(shi,ge);
void init();
void delay(unsigned int i) //¶¨Ê±º¯Êý
{ unsigned int j;
for(;i>0;i--)
for(j=0;j<333;j++)
{;}
}
void display(shi,ge) //¶¯Ì¬ÏÔʾº¯Êý
{
b=1;
GPIO_DIG= DIG_CODE[shi];
b=0;
delay(1);
a=1;
GPIO_DIG= DIG_CODE[ge];
a=0;
delay(1);
}
void main()
{
//c=0;
init();
while(1)
{
if(time==60)
time=0;
shi=time/10;
ge=time%10;
display(shi,ge);
}
}
void t0_func() interrupt 3
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
count++;
if(count==100)
{
count=0;
time++;
}
}
void init()
{
a=0;
b=0;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
time=0;
count=0;
}