I heard that using digital io pins in INPUT_PULLUP mode is much reliable and stable than in the case of using them in INPUT MODE.Then why is INPUT MODE still used...I mean Why isn't INPUT_PULLUP mode put as default ??
1 Answer
When the internal pullups are activated, a small amount of current is sourced by the pin's circuitry whenever the input is low.
That means that to drive the signal low, an external driver must not only sink current to discharge the capacitance of the internal and external circuitry, but it must continue doing so to dominate the attempt of the internal pullup to make the line high so that the voltage of the resistive voltage divider formed by the internal and external resistors is low enough to be an unambiguous low.
This means that the external circuit must be stronger - not normally a problem for an active device, but potentially an issue for monitoring some very high impedance external circuit. So for example, if you wanted an external pull-down resistor, it would have to be substantially lower in value than the internal pull-up.
It also makes low power design (long life on batteries) difficult, as a system cannot take advantage of the best micropower suspend modes when any signal is being asserted against the direction of a pulling resistor. With just one or two such cases you might still get reasonable life when using flashlight batteries, but not with a coin cell, something a well designed ATmega circuit can presently do.
After seeing Igor's comment, and re-reading your post, it seems maybe you are asking why the default is to have them disabled, rather than why you have the ability enable/disable them at all. Most likely, the reason the Arduino core software has them disabled by default is because the ATmega resets that way. As to why the ATmega resets that way, you might have to ask the design engineers, but generally it has been the norm to have an MCU reset to a state where it has the least influence on the external circuitry. However, that is not necessarily the best - floating (undriven) inputs can potentially cause a typical CMOS input structure to consume more power than ones weakly driven to a known value.
-
I haven't done any low power with AVR, but on larger SoCs it's common to have different pin configuration for sleep mode, where only the wakeup sources are left configured active, while the rest is programmed to minimize overall battery current. In this case the pullup could be disabled during sleep and re-enabled after wakeup. Assuming that the input is sufficiently stable. But most likely one wants to debounce it anyway, if it's a button or similar jittery source. Commented Apr 21, 2016 at 17:23
-
I guess I had actually misread the question a little bit, and instead answered a different one about why the pullups are not permanently enabled, rather than why they merely default to being disabled. In terms of what to do during sleep/suspend, typically if you have something like a switch rather than a bipolar external driver, you want a pulling resistor holding the signal in the state expected while asleep, and to wake and deal with any change. Commented Apr 21, 2016 at 17:48