Power consumption of pins in different pin modes

I am building a project that is battery-powered and must have a low power consumption. From this Low Power Arduino! Deep Sleep Tutorial - YouTube video, I know that floating pins consume more power than pins set to output HIGH or LOW. I am wondering if putting the pins in INPUT_PULLUP mode would save even more power since they are no longer floating and are not be outputting a voltage. I would love to know the difference between these two approach. P.S. I don't have a current meter that is precise enough to do the measurements myself.

Go to this page and scroll about 1/8 of the way down. Here is the summary table from Gammon Forum:

Testing in SLEEP_MODE_PWR_DOWN:

All pins as outputs, and LOW: 0.35 µA (same as before).

All pins as outputs, and HIGH: 1.86 µA.

All pins as inputs, and LOW (in other words, internal pull-ups disabled): 0.35 µA (same as before).

All pins as inputs, and HIGH (in other words, internal pull-ups enabled): 1.25 µA.

wSo it seems like a good practice to set all unused pins to low.

wilykat:
wSo it seems like a good practice to set all unused pins to low.

Or do nothing, as they default to inputs ?

srnet:
Or do nothing, as they default to inputs ?

That's floating inputs which will result in constant flipping of all the logic gates resulting in higher power consumption.

So the point is to not let the pins be in a floating state?

That would be my approach.

Yom092090:
So the point is to not let the pins be in a floating state?

You could follow the recommendation provided by Atmel in the processor's datasheet. Given the fact that they make power consumption guarantees it seems likely they also provide guidelines for meeting those guarantees.

What doesn't make sense to me is that gammon's tests with pullups on (as atmel suggests) has higher power consumption than when the pins are left floating (which atmel says will result in increased power consumption)....

DrAzzy:
What doesn't make sense to me...

I believe Nick ran the tests shortly after acquiring the current mirror. Maybe there were some kinks that had not been worked out.

Floating inputs do not have a CONSTANT current consumption. It depends on what voltage they float to, which depend on... lots of random factors. If you have floating inputs, you can change the Current consumption by waving your hand nearby...

:smiley: This is the best joke I have heard today ! Cheers! Indeed, I am happy with my current consumption (500uA) so I will leave as it is, probably I will not get lower, if I consider and changing the ports as ins to outs and vice versa... Thanks anyway!

Best.

500uA seems really high!

Did you forget to turn off the ADC before you put it to sleep? That alone takes off ~270uA from the sleep mode power consumption.

DrAzzy:
What doesn't make sense to me is that gammon's tests with pullups on (as atmel suggests) has higher power consumption than when the pins are left floating (which atmel says will result in increased power consumption)....

I don't believe the Nick Gammon's results either. Maybe some leakage on his test board? Or damaged chip? Sadly I don't have time to test it.

Anyway in all sleep modes except for Idle sleep the input digital buffer is disabled (unless the pin is used as a wake up source) so there should be no difference if the pin is HIGH, LOW or even floating. From my tests the worst case current consumption of a floating pin is 100uA, but is much less typically (@ room temperature!). I think the additional current consumption even with all pins floating is small compared to the current consumption of the CPU running @16MHz.

Smajdalf:
Anyway in all sleep modes except for Idle sleep the input digital buffer is disabled (unless the pin is used as a wake up source) so there should be no difference if the pin is HIGH, LOW or even floating. From my tests the worst case current consumption of a floating pin is 100uA, but is much less typically (@ room temperature!). I think the additional current consumption even with all pins floating is small compared to the current consumption of the CPU running @16MHz.

I have an ATMEGA1284P on a breadboard at the moment, checking a designs sleep current.

Its set to wakeup on an interrupt from a DS3231 RTC Alarm going off.

I have only 10 of the 32 I\O pins available in use, the rest are not connected or configured at all, so will be defaulting to inputs and floating.

The board setup is ATMEGA1284P, TPL5010 acting as Watchdog, 2Kbyte FRAM, DS3231 RTC, MIC2005 high side switch turning off a SX1278 LoRa device.

Sleep current of the lot is 1.0uA and stable, waving of hands or touching un-used pins makes no differance.

Clearly by leaving 22 unused pins as inputs I am doing something wrong ?

srnet:
Clearly by leaving 22 unused pins as inputs I am doing something wrong ?

The Datasheet says unused pins should be configured as input pullup to prevent pins floating but not as output to prevent short circuit in case of unintentional connection somewhere. I am not sure if the advice is generally true. Since floating outputs should not consume current during a deep sleep but driving then to a defined level may cause additional current consumption due to leakage I think it is better to let them float if the MCU spends 99.9% time in sleep. Ofc if DIDRx register is available for the unused pins it is worth to disable the input buffer.
OTOH if the application cannot go to a deep sleep but runs at a low speed to conserve power instead, the additional power draw from floating pins may be significant.