0
\$\begingroup\$

I am using GPIO expanders (MCP23017) for an array of buttons. Each button is connected between GND and an input pin of the expander. I've enabled the 100k internal pull-up resistor on the MCP23017 (and verified that I did this correctly), so the input pin should idle high at 5V and the button will pull it low when pressed.

This does not happen. When unpressed, the voltage measured between GND and the input pin is about .1-.2V (should be 5V). When I measure between the input pin and the Vcc that I'm providing the expander, the difference is also about .1-.2V (should be 0V). The difference between GND and Vcc is a consistent 5V.

When I press the button, it works properly, pulling the input pin to 0, but why will the input pin not idle high? Is it floating? I can't figure out what voltage it's at and my measurements don't make any sense. What am I doing wrong?

MCP23017 Datasheet (I have IOCON set to 0xD0 and GPPUA, GPPUB, GPINTENA, GPINTENB set to 0xFF, all other registers are default).

\$\endgroup\$
11
  • 1
    \$\begingroup\$ What voltmeter are you using, and what is the logic state of the pin as reported by the GPIO expander? \$\endgroup\$ Commented Mar 3 at 22:04
  • \$\begingroup\$ Check the resistance of the button in the open condition vs the internal pull. Check the voltage when the button is not present and the voltage you are giving the expander. Sometimes using too many expanders and not having enough current for all their pullups is the issue. \$\endgroup\$
    – Abel
    Commented Mar 3 at 22:10
  • \$\begingroup\$ Note, at VDD=5v, the pull-up is spec'd at 75µA typical (40-115µA), not 100kΩ. \$\endgroup\$
    – Attie
    Commented Mar 3 at 22:45
  • 1
    \$\begingroup\$ It's not posible for GND->Pin to measure 100-200mV, and Pin->VCC (5v) to also measure 100-200mV... do you trust your measurement equipment (cables in the correct holes, DC not AC, high-impedance, etc...) and technique (definately making good electrical contact)? \$\endgroup\$
    – Attie
    Commented Mar 3 at 22:46
  • 1
    \$\begingroup\$ @DamienD You helped me to discover my rookie mistake, it was a coding issue. The IOCON register has a bit "BANK" which moves the location of various registers, including itself. I would write IOCON, go to write/read it again, and it had moved (from 0x0A to 0x05) along with the GPIO registers, which makes it clear why those were reporting nonsense data and why certain pins were held high (I was not writing to the GPPU register but rather its previous location). Thank you so much! Sorry to take you on a wild goose chase. \$\endgroup\$
    – Nate.Olson
    Commented Mar 5 at 5:07

0

Your Answer

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

Browse other questions tagged or ask your own question.