The pullup SETTINGS (ie. the register value) will certainly remain unchanged across changes of direction etc - nothing changes them except explicit writes by your program. So your observed behaviour is entirely as expected.The behavior of the pull-ups was also interesting. With pins set to inputs and pullups on, and then switching from inputs to outputs, the output pins are always initially set to zero, then switched to high and low according to the value of gpio_put_masked. However, when subsequently switched back to inputs, they all go high again. In other words, the pull-up status is exactly what it was originally. This does seem to suggest that the pull-ups stay on throughout, confirming as gmx indicates, that it is probably best to disable them explicitly when not in use.
The question is what actually happens on the pin when the pullup is enabled and the pin is an output: does the pad logic disable the pullup during output mode to save energy, or does it remain on, allowing about 50 microamps of current to wastefully circulate inside the chip between pullup and drive transistor?
Some (non-RasPi) chips are clearly documented as doing one or the other. RP2040 documentation doesn't expressly answer this point, though there is a hint that the pullup remains on. It is very difficult to verify this experimentally as the current is so small.
However, since the current is so small it doesn't really matter (except in ultra-low-power battery operated applications, for which RP2040/Pico just isn't well suited in the first place).
Personally, I'd leave the pullups on in simple applications. If doing something more complex, my first thought would be to explicitly drive the pin high as an output for a brief moment before returning it to an input with the pullup enabled - so as to 'park' the pin in the high state rather than waiting for the pullup to slowly drift it up there.
Statistics: Posted by arg001 — Thu Oct 24, 2024 7:47 am