P3_4连蜂鸣器,高通. 请各位走过路过帮忙看看,调试的时候就是出不来,在线等待
void keyscan(uchar key) // 键盘扫描
{
P0=0xff;
P2_3=0;P2_4=0;P2_5=0;P2_6=0;P2_7=0;
while(P0!=0xff)
{
delay(1);
while(P0!=0xff)
{
P2_3=0;P2_4=1;P2_5=1;P2_6=1;P2_7=1;
switch(P0)
{
case 0xfe:key=0x01;break; // 键符 TIME
case 0xfd:key=0x02;break; // 键符 LAST
case 0xfb:key=0x03;break; // 键符 AUX
case 0xf7:key=0x04;break; // 键符 1
case 0xef:key=0x05;break; // 键符 2
case 0xdf:key=0x06;break; // 键符 3
case 0xbf:key=0x07;break; // 键符 4
case 0x7f:key=0x08;break; // 键符 5
default:break;
while(key!=0)
{ P3_4=1;}
P3_4=0;
}
P2_3=1;P2_4=0;P2_5=1;P2_6=1;P2_7=1;
switch(P0)
{
case 0xfe:key=0x09;break; // 键符 WIDE
case 0xfd:key=0x0a;break; // 键符 TELE
case 0xfb:key=0x0b;break; // 键符 NEAR
case 0xf7:key=0x0c;break; // 键符 FAR
case 0xef:key=0x0d;break; // 键符 CLOSE
case 0xdf:key=0x0e;break; // 键符 OPEN
case 0xbf:key=0x0f;break; // 键符 PATRN
case 0x7f:key=0x10;break; // 键符 SHOT
default:break;
while(key!=0)
{ P3_4=1;}
P3_4=0;
}
P2_3=1;P2_4=1;P2_5=0;P2_6=1;P2_7=1; switch(P0)
{
case 0xfe:key=0x11;break; // 键符 MENU
case 0xfd:key=0x12;break; // 键符 SITE
case 0xfb:key=0x13;break; // 键符 SHIFT
case 0xf7:key=0x14;break; // 键符 ALARM
case 0xef:key=0x15;break; // 键符 LOCK
case 0xdf:key=0x16;break; // 键符 ACK
case 0xbf:key=0x17;break; // 键符 USER
case 0x7f:key=0x18;break; // 键符 AUTO
default:break;
while(key!=0)
{ P3_4=1;}
P3_4=0;
}
P2_3=1;P2_4=1;P2_5=1;P2_6=0;P2_7=1;
switch(P0)
{
case 0xfe:key=0x19;break; // 键符 ON
case 0xfd:key=0x1a;break; // 键符 NEXT
case 0xf7:key=0x1b;break; // 键符 OFF
case 0xef:key=0x1c;break; // 键符 MON
case 0xdf:key=0x1d;break; // 键符 C
case 0x7f:key=0x1e;break; // 键符 CAM
default:break;
while(key!=0)
{ P3_4=1;}
P3_4=0;
}
P2_3=1;P2_4=1;P2_5=1;P2_6=1;P2_7=0;
switch(P0)
{
case 0xfe:key=0x1f;break; // 键符 SALVO
case 0xfd:key=0x20;break; // 键符 HOLD
case 0xfb:key=0x21;break; // 键符 RUN
case 0xf7:key=0x22;break; // 键符 6
case 0xef:key=0x23;break; // 键符 7
case 0xdf:key=0x24;break; // 键符 8
case 0xbf:key=0x25;break; // 键符 9
case 0x7f:key=0x26;break; //键符 0
default:break;
while(key!=0)
{ P3_4=1;}
P3_4=0;
}
}
}
} |