有个程序不知道哪里错了 求大神解答
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit K1 = P1^4;
sbit K2 =P1^5;
sbit P1_7=P1^7;
uint time;
uchar count;
uchar sec;
uchar sc;
uchar key_s, key_v;
/**********************************函数声明***********************************/
bit scan_key();
void keyscan(void);
void proc_key();
void display(void);
uchar data dis[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void delayms(unsigned char ms);
/**********************************主函数*************************************/
void main(void)
{
P0 = 0xff; // 关闭数码管显示
P2 =0xff;
TMOD= 0x51;
TH0 = 0x4c;
TL0 = 00;
TH1= 00;
TL1= 00;
IE = 0x82;
TR0= 0;
TR1= 0;
P1_7=1;
key_v= 0x03;
while(1)
{
keyscan();
display();
}
}
void keyscan(void)
{
if(scan_key())
{
delayms(10);
if(scan_key())
{
key_v = key_s;
proc_key();
}
}
}
void display(void)
{
if(TL1*4>90)
{
P1_7=0;
}
else
{
P0=dis[TL1*4/10];
P2=0xfd;
delayms(2);
P0=dis[TL1*4%10];
P2=0xfe;
delayms(2);
P0=dis[sec/10];
P2=0X7F;
delayms(2);
P0=dis[sec%10];
P2=0XBF;
delayms(2);
}
}
bit scan_key()
{
key_s = 0x00;
key_s |= K2;
key_s <<= 1;
key_s |= K1;
return(key_s ^ key_v);
}
void proc_key(void)
{
if((key_v & 0x01) == 0)
{
TR0=1;
TR1=1;
}
else if((key_v & 0x02) == 0)
{
TR0=0;
TR1=0;
}
}
void timer0() interrupt 1
{
time++;
sc++;
if(sc==20){sec++;sc=0;}
if(time==1200)
{
time=0;
TR0=0;
TR1=0;
}
else
{
TH0 = 0x4c;
TL0= 0x00;
}
}
void delayms(unsigned char ms)
{
unsigned char i;
while(ms--)
{
for(i = 0; i < 120; i++);
}
}
是将外部端口(P3.5)的数据显示在出来的,K1(P1.4)、K2(P1.5)是开关,分别是启动和关闭定时器和计数器的 但是我启动之后 数码管全显示88888888 (2个四位的数码管) 求指出错在哪,并修正下 感激不进啊