请各位大神帮我看下这段解码程序,每次按下同一个按键,解出来的码值都不同,请问是哪里出问题了?
void int0() interrupt 0
{ U8 TA;
U8 i , j;
EX0 = 0;
TA = 0 ;
//总共延时2ms
TR1 = 1;
while(ZI);
if(p32 != 0)
{
EX0 = 1;
return;
}
while(p32 == 0);
//延时2.5ms
TH1 = 0xff ;
TL1 = 0x06;
TR1 = 1;
ZI = 1;
while(ZI) ;
while(p32 != 1) // 2.5ms的连发码
{
EX0 = 1;
return;
}
if(TF1 != 0)
TF1 =0;
//接收4.5ms的高电平
while(p32 == 1);
for(j=0;j<4;j++)
{
for(i=0;i<8;i++)
{
//接收0.56ms的低电平
while(p32 == 0);
//延时0.6ms
TH1 = 0xfd;
TL1 = 0xa8;
TR1 = 1;
ZI = 1;
while(ZI);
if(p32 == 1)
TA |= 0x80;
TA >>= 1;
}
SHUZU[j] = TA;
}
if(SHUZU[2] != ~SHUZU[3])
{
EX0 = 1;
SHUZU[2] = 0;
p03 = 0;
return ;
}
EX0 = 1;
}
void timer1() interrupt 3
{
ZI = 0 ;
}
|