求大神帮助一下啊 报错了
- #include <reg52.h>
- #include <intrins.h>
- unsigned char code SEGtable[]=
- {
- 0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0x00
- };
- unsigned char code keycodetable[]=
- {
- 0x11,0x12,0x14,0x18,0x21,0x22,0x24,0x28,0x41,0x42,0x44,0x48,0x81,0x82,0x84,0x88
- };
- void delay()
- {
- unsigned char i;
- for(i=0;i<200;i++);
- }
- unsigned char keys_scan()
- {
- unsigned char scode,kcode,i,k;
- P1=0xf0;
- if((P1&0xf0)!=0xf0)
- {
- delay();
- if((P1&0xf0)!=0xf0)
- {
- scode=0xfe;
- for(k=0;k<4;k++)
- {
- P1=scode;
- if((P1&0xf0)!=0xf0)
- {
- kcode=P1;
- for(i=0;i<16;i++)
- {
- if(kcode == keycodetable[i])
- return i;
- }
- }
- else
- sCode = _cro1_(scode,1);
- }
- }
- }
- return -1;
- }
- unsigned char switchkeyno(unsigned char temp)
- {
- unsigned char keypadno;
- switch(temp)
- {
- case 0: keypadno = 7; break;
- case 1: keypadno = 7; break;
- case 2: keypadno = 1; break;
- case 3: keypadno = 10; break;
- case 4: keypadno = 8; break;
- case 5: keypadno = 5; break;
- case 6: keypadno = 2; break;
- case 7: keypadno = 0; break;
- case 8: keypadno = 9; break;
- case 9: keypadno = 6; break;
- case 10: keypadno = 3; break;
- case 11: keypadno = 11; break;
- case 12: keypadno = 12; break;
- case 13: keypadno = 13; break;
- case 14: keypadno = 14; break;
- case 15: keypadno = 15; break;
- default:{}
- }
- return keypadno;
- }
- int main(void)
- {
- unsigned char keyno = -1;
- while(1)
- {
- keyno = keys_scon();
- if(keyno != -1)
- {
- P2 = SEGtable[switchkeyno(keyno)];
- }
- }
- }
复制代码
|