3

I've discovered pigpio and am starting to learn to use it with Python. I thought I would use it to "discover" the pullup status of a pin before setting it, but while mode has both .set_mode() and .get_mode() methods as shown in this documentation, there is only the .set_pull_up_down() method, apparently without a corresponding "getter method".

Question: Is there a way to read the pullup status of a GPIO pin in python with, or if not, without pigpio?

If it is relevant, I have a RPi 3 and using Raspbian 4.4.21-v7+

2 Answers 2

6

It is not possible.

Page 100 of BCM2835 ARM Peripherals

GPIO Pull-up/down Register (GPPUD)

SYNOPSIS

The GPIO Pull-up/down Register controls the actuation of the internal pull-up/down control line to ALL the GPIO pins. This register must be used in conjunction with the 2 GPPUDCLKn registers.

Note that it is not possible to read back the current Pull-up/down settings and so it is the users’ responsibility to ‘remember’ which pull-up/downs are active. The reason for this is that GPIO pull-ups are maintained even in power-down mode when the core is off, when all register contents is lost.

The Alternate function table also has the pull state which is applied after a power down.

1
  • Bingo! Thank you for the speedy and well-reference answer! I'll be sure to consult the document before asking my next pigpio question.
    – uhoh
    Dec 17, 2017 at 12:22
1

As pointed out above, for this chip, there is no register which stores the values. What actually happens is you write to GPPUD to describe what PU/PD/PN state you want, then you latch/clock that value into your GPIO pins of interest via GPPUDCLK0 and GPPUDCLK1. Those same registers could then perform another similar operation right after so there's no memory of it, just the actual resistance across the pin (driven by the unreadable latch).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.