4 Replies Latest reply on Apr 11, 2014 10:47 AM by lewis_1490776 Branched to a new discussion.

    Do all GPIO ports support pullup/pulldown when used as an input?

    lewis_1490776

      I am having trouble getting port 0 pin 32 to operate in an input with pull-down enabled mode.

      It seems to work for other ports such as P2. 

      Are these modes supported on all GPIO ports?

       

      I am using a custom board based on the 20732S.

        • 1. Re: Do all GPIO ports support pullup/pulldown when used as an input?
          ArvindS_76

          Yes, all GPIOs can have either a pull-up or an internal pull-down. Note that the pull-up/down will take effect only after programming the configurations, so you cannot use this when the GPIO is expected to be pulled a specific way before that (like when the device is just being powered on).

           

          Each port has only 16 pins, so port 0, pin 32 is not valid. How are you using gpio_configurePin()?

          • 2. Re: Do all GPIO ports support pullup/pulldown when used as an input?
            lewis_1490776

            OK, so I tried two ways:

              gpio_configurePinWithSingleBytePortPinNum

               (32, GPIO_OUTPUT_DISABLE | GPIO_INPUT_ENABLE | GPIO_PULL_UP, 0);

              gpio_configurePin

               (2, 0, GPIO_OUTPUT_DISABLE | GPIO_INPUT_ENABLE | GPIO_PULL_UP, 0);


            Only the second way works.  This is baffling to me as I would have thought that the single byte version is implemented by simply calling the two byte version with (port/16, port%16, ...)


            BTW I also noticed that even with the PUART disabled (I put NULL in the config call), P32 is still outputting some serial data during boot time. 


            • 3. Re: Do all GPIO ports support pullup/pulldown when used as an input?
              ArvindS_76

              /// Configures a GPIO. This function is the same as configurePin(BYTE port, BYTE pin, UINT16 config)

              /// except, the port and pin number is passed as single byte. Bit 7:5 is port, and 4:0 is pin.

              ///   \param gpio[7:5] - port id(0-4). Must be in range 0-2 or results are undefined.

              ///   \param gpio[4:0] - pin id(0=LSB, 15=MSB). Must be in range or results are undefined.

              ///                 For port 0 and port 1, valid range is 0-15, for port 2, valid range is 0-7

              ///   \param config - configuration.

              ///   \param outputVal - output value. ignored if output is not enabled.

              void gpio_configurePinWithSingleBytePortPinNum(BYTE gpio, UINT16 config, BYTE outputVal)

               

              So, try this instead:

               

              gpio_configurePinWithSingleBytePortPinNum

                 (2 << 5, GPIO_OUTPUT_DISABLE | GPIO_INPUT_ENABLE | GPIO_PULL_UP, 0);

              • 4. Re: Do all GPIO ports support pullup/pulldown when used as an input?
                lewis_1490776

                OK, that works.  I guess I did not read the documentation carefully..