2 Replies Latest reply on Jul 1, 2014 4:53 AM by user_14586677

    Read GPIO input

    cheng.chen

      Hi,

         

      I have a issue with reading GPIO input value with the code as below:

         

      // set P0[2] drive mode = highZ

         

      PRT0DM2&=~0x04;

         

      PRT0DM1|=0x04;

         

      PRT0DM0&=~0x04;

         

      //read P0[2] input to temp 

         

                      BYTE temp=0;

         

      temp |= (PRT0DR&0x04)<<7;

         

       

         

      P0[2] is set as StdCPU. While I give a 5V input to P0[2] port, and expect the variable temp will have a value of 80h after executing the above code. However, the temp value is always 0. I am wondering it is the correct way to read the input of port P0[2]?

         

      appreciate any help and suggestion.

         

       

         

      Thanks,

         

      cc