questions when using psoc3 to develop a keypad scan program

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello,everyone!

   

i tried to use psoc3 to develop a keypad scan programa, here is the code :

   

void KeyScan()
             {
               Port0(1);   //output b11111111 to the port0
               Port0_4(0);
               Port0_5(0);
               Port0_6(0);
               Port0_7(0);
               temp1=PRT0DR;
              
               Port0(1);
               Port0_0(0);
               Port0_1(0);
               Port0_2(0);
               Port0_3(0);
               temp2=PRT0DR;
              
               x=temp1&temp2;
              
               switch(x){
                  case 0x11:key=0;break;
                  case 0x21:key=1;break;
                  case 0x41:key=2;break;
                  case 0x81:key=3;break;
                  case 0x12:key=4;break;
                  case 0x22:key=5;break;
                  case 0x42:key=6;break;
                  case 0x82:key=7;break;
                  case 0x14:key=8;break;
                  case 0x24:key=9;break;
                  case 0x44:key=10;break;
                  case 0x84:key=11;break;
                  case 0x18:key=12;break;
                  case 0x28:key=13;break;
                  case 0x48:key=14;break;
                  case 0x88:key=15;break;
                  default: key=6;break;
                  }
                  
               }

   

the problem is befor 8,all the data is good, lcd can display the data correctly,but after 8,the results is always 6,that is the default output, it seems the p0[2],p0[3] can not detect the signal,i am using cy8c29466,can anyone tell me the reason,thank you very much!

0 Likes
2 Replies
Anonymous
Not applicable

Can you tell us more about your hardware setup. Possibly a schematic should help. Just with the code it is tough to debug the issue.

0 Likes
Anonymous
Not applicable

i am using a 4*4 keypad ,and connect the rows to P0[0]--P0[3],the columns to P0[4]--P0[7];

   

set the pins as pull down mode,

   

and the problem is that it seems the P0[2] and P0[3] can not get the signal, because other pins works fine

0 Likes