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

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

cross mob
legic_1490776
Level 5
Level 5
25 likes received 10 likes received First like received

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.

0 Likes
1 Solution

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

View solution in original post

0 Likes
4 Replies
asridharan
Employee
Employee
10 comments on KBA 5 comments on KBA First comment on KBA

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()?

0 Likes

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. 


0 Likes

/// 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);

0 Likes

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

0 Likes