完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
程序无法在防真上显示 #include #include #include #include #define INT8U unsigned char #define INT16U unsigned int #define KEY_PORT P1 //键盘端口定义 ***it SPK=P3^7; INT8U KeyNo=0xFF; //当前按键序号,有效范围为0-15,0xFF表示无按键 extern void delay_ms(INT16U); //----------------------------------------------------------------- // 判断键盘矩阵是否有键按下 //----------------------------------------------------------------- INT8U KeyMatrix_Down() { KEY_PORT=0x0F;delay_ms(1); return KEY_PORT!=0x0F?1:0; } //----------------------------------------------------------------- // 4*3键盘矩阵扫描 //----------------------------------------------------------------- void Keys_Scan() { switch (KEY_PORT) {case 0x0E:KeyNo=0;break; case 0x0D:KeyNo=1;break; case 0x0B:KeyNo=2;break; } KEY_PORT=0xF0;delay_ms(1); switch (KEY_PORT) {case 0xE0:KeyNo+=0;break; case 0xD0:KeyNo+=3;break; case 0xB0:KeyNo+=6;break; case 0x70:KeyNo+=9; } } INT8U code Keypad_Chars[12][6] = { "1 ", "2ABC", "3DEF", "4GHI", "5JKL", "6MNO", "7PQRS","8TUV", "9WXYZ", "*", "0+", "#" }; extern INT8U KeyNo; //键值 INT8U Inner_Idx = 0; //同一按键的内部字符索引 INT8U tSpan = 0; //同键位连续按键的时间间隔 INT8U Buffer_Index = 0; //英文/数字输入缓冲索引 char Input_Buffer[16]; //输入缓冲空间 INT8U ENG_TEL = 1; //输入内容切换标识(ENG:英文输入,TEL:电话输入) extern void delay_ms(INT16U ms); extern INT8U KeyMatrix_Down(); extern void Keys_Scan(); void Beep() { INT8U i; for(i=0;i<60;i++) {SPK=!SPK; delay_ms(1); } SPK=1; delay_ms(100); } void T0_INT() interrupt 1 {TH0=-50000>>8; TL0=-50000&0xFF; if(tSpan<50) tSpan++; else TR0=0; } void Function_Key_Process() { if(KeyNo==9) {ENG_TEL=!ENG_TEL; Inner_Idx=ENG_TEL?1:0; } Buffer_Index=0; Input_Buffer[0]=' |