Switching between OUTPUT and INPUT_PULLUP using registers

MrBean
Posts: 11
Joined: Wed Aug 17, 2022 1:55 pm

Re: Switching between OUTPUT and INPUT_PULLUP using registers

Postby MrBean » Sat Nov 22, 2025 11:31 pm

It turns out that Arduino pinMode(pin, OUTPUT) puts the GPIO pin in GPIO_INPUT_OUTPUT mode, that is, in driven rather than open drain mode. If you read the pin configuraton with gpio_config_t then both input and output are turned on, but the 'od' and is not. Switching from input to input_output automatically disables the pullup.

I also discovered that although the data bus can operate in open drain mode, the control bus signals have to be driven, so I can't just use the _OD option across the board. On the other hand, using INPUT_OUTPUT mode without _OD emulates pinMode() and does work. I am still unsure why pure OUTPUT mode does not work, but I am pretty sure that its related to how digitalRead() behaves. It behaves differently between OUTPUT and INPUT_OUTPUT modes.

It may be that I need to make changes to my program to account for this, but at least I do now have a set of functions that work as intended.

Thank you for the helpful comments.

Who is online

Users browsing this forum: meta-externalagent, PetalBot and 7 guests