#include<reg52.h>
unsigned char code Ledchar[4][4] = {
{0x3f,0x06,0x5b,0x4f},
{0x66,0x6d,0x7d,0x07},
{0x7f,0x6f,0x77,0x7c},
{0x39,0x5e,0x79,0x71},
};
unsigned char keysta[4][4] = {
{1,1,1,1},
{1,1,1,1},
{1,1,1,1},
{1,1,1,1},
};
void main()
{
unsigned char keyup[4][4] = {
{1,1,1,1},
{1,1,1,1},
{1,1,1,1},
{1,1,1,1},
};
sta
tic unsigned char i,j;
EA = 1;
ET0 = 1;
TMOD = 0X01;
TH0 = 0XFC;
TL0 = 0X18;
TR0 = 1;
P0 = Ledchar[0][0];
while(1)
{
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
if(keysta
[j] != keyup[j])
{
if(keyup[j] == 0)
{
P0 = Ledchar[j];
}
}
keyup[j] = keysta[j];
}
}
}
}
void keyscan()
{
unsigned char keybuf[4][4] = {
{1,1,1,1},
{1,1,1,1},
{1,1,1,1},
{1,1,1,1},
};
static unsigned char th,tl;
static unsigned char i,j;
P3 = 0xf0;
th = P3;
switch(th)
{
case 0xe0: i = 0; break;
case 0xd0: i = 1; break;
case 0xb0: i = 2; break;
case 0x70: i = 3; break;
default:break;
}
P3 = 0x0f;
tl = P3;
switch(tl)
{
case 0x0e: j = 0; break;
case 0x0d: j = 1; break;
case 0x0b: j = 2; break;
case 0x07: j = 3; break;
default:break;
}
if((keybuf[j] & 0x0f) == 0x00)
{
keysta[j] = 0;
}
if((keybuf[j] & 0x0f) == 0xff)
{
keysta[j] = 1;
}
}
void TimeInt() interrupt 1
{
TH0 = 0XFC;
TL0 = 0X18;
keyscan();
}
为什么总是卡在主函数P0 = Ledchar[0][0];这里
大神求教
一周热门 更多>