2 Replies Latest reply on May 6, 2011 7:47 AM by chen.nate

    questions when using psoc3 to develop a keypad scan program

    chen.nate

      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!