1 Reply Latest reply on Aug 22, 2019 8:18 PM by MoTa_728816

    Digital Input Pins on different ports

    DaHu_285096

      Hi

       

      I have an issue on PSOC 5LP device.

       

      There are 2 projects where I use a HEX rotary switch.

       

      I do not use external pullup but rely on the digital pin onboard pull up resistors.

       

      One project has the Switch connected to port pins P0.7 through to P0.4 and works fine. (and has worked fine like this for a couple of years I have built that project)

       

      The other project has switch connected to pins P5.6 through P5.4 and LSB on P12.7 and I cannot read the switch properly. I only every get "1" or "0" from various switch settings. It appears P12.7 LSB works but no reading from the upper 3 bits on P5.

       

      I checked Vio pins an they have 3.3V ok. The continuity between pins and switch are correct and there is no short. The switch is grounded correctly. If I remove power and measure continuity on switch as I change values, I get correct values.

      This occurs on all the boards I build so I am confident it is not an assembly issue.

       

      Is there something on port P5 when used as digital input that is different from P0? I am not sure what else to try.

       

      Thanks

        • 1. Re: Digital Input Pins on different ports
          MoTa_728816

          Hi,

           

          At first I suspected that you are using a pin of following style

          000-Pins_with_width.JPG

          It may require to use same port to be configured from PSoC Creator GUI.

           

          So I changed the schematic as below

          002-schematic.JPG

          Pin list

          003-pin-assign.JPG

           

          main.c

          ==========================

          #include "project.h"

          #include "stdio.h"

           

          char str[128] ; /* print buffer */

          void print(char *str)

          {

              UART_PutString(str) ;

          }

           

          uint8_t read_enc(void)

          {

              uint8_t value = 0 ;

              if (HexEnc3_Read()) {

                  value |= 1 ;

              }

              value <<= 1 ;

              if (HexEnc2_Read()) {

                  value |= 1 ;

              }

              value <<= 1 ;

              if (HexEnc1_Read()) {

                  value |= 1 ;

              }

              value <<=1 ;

              if (HexEnc0_Read()) {

                  value |= 1 ;

              }

              return(value) ;

          }

           

          void splash(void)

          {

              sprintf(str, "GPIO Input Test (%s %s)\r\n",

                  __DATE__, __TIME__) ;

              print(str) ;

          }

           

          int main(void)

          {

              uint8_t value ;

              uint8_t pre_value = 0xFF ;

            

              CyGlobalIntEnable; /* Enable global interrupts. */

            

              UART_Start() ;

            

              splash() ;

           

              for(;;)

              {

                  value = read_enc() ;

                  if (value != pre_value) {

                      sprintf(str, "%04X\n", value) ;

                      print(str) ;

                  }

                  pre_value = value ;

                  CyDelay(1000) ;

              }

          }

           

          ==========================

           

          Then I connect each pin to GND and VCC_via_resistor

          the Tera Term output was

          001-TeraTerm-log.JPG

          So I think that we can use P5[6], P5[5], P5[4], P12[7] as 4 bit input.

           

          May be you need to double check your circuit, especially connection between the encoder and P5[] pins.

           

          I used CY8CKIT-050

          IMG_3784.JPG

           

          moto