Output pin mode change before sleep

Hello,

I ran into a method which I don't really understand --> Power saving techniques for microprocessors

There are several examples where OUTPUT pin set to HIGH/LOW state after waking from sleep (e.g. Waking from sleep with a timer, Powering off external devices, etc.). In these sketches, OUTPUT pin mode is changed to INPUT before going back to sleep again. Why?

As tested in Configuring pins as inputs/outputs section, overall current consumption should be the same if pin is in OUTPUT LOW or in INPUT mode state. I could think of some safety reason for this, if a voltage is accidentally connected to OUTPUT LOW pin, it could cause troubles. Is this the case?

Thanks in advance.

Hi @amazed

I guess it's because you don't want the microcontroller's "power" pin to end up sinking current back through the RTC's 5V from its SCL and SDA pins.

Hi, meanwhile I realized I was not enough observant.

Once finished we set the pin to input first, and then to low, again to save draining the capacitor

It's because of the the bypass capacitor.

Whether you set pins to output, and high or low, or to input pullup or indeed input, when going to sleep, depends on what devices or components you actually have connected.

There is no universal optimum method that I am aware of.

I understand.

The twist in this particular example, is that AFAIK, DS1307 doesn't need any supply voltage to be able to communicate via I2C (if battery is inserted of course).

If your desigining a PCB, then rather than rely on 'AFAIK' you have to try it for real, before having the PCBs made.

If your desigining a PCB, then rather than rely on 'AFAIK' you have to try it for real, before having the PCBs made.

You're right, DS1307 operation should be confirmed.

But I've used DS3231 modules without VCC applied, it works just fine.

From the datasheet:

  • VCC pin: if not used, connect to ground.
  • SDA, SCL pin: The pullup voltage can be up to 5.5V, regardless of the voltage on VCC.
  • I2C interface: The I2C interface is accessible whenever either VCC or
    VBAT is at a valid level.

Pins which are allowed to float can cause excess power consumption in sleep mode.
For a project with I2C devices, it should be enough to call Wire.end() then set all pins as required for minimum power consumption before entering sleep mode. On waking, undo it all in the reverse order th call Wire.begin().
As recommended above, test carefully.

+1.

When I got serious about extreme low power, it allowed me to need to buy a new meter with better very low current measuring quality.

There is no fun to be had like trying to find 9 uA of current when your theory says it should be less than 1.0.

Yes I have no life.

Get a good meter and use it, there is no substitute for measurement of the full up circuitry and code.

a7

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.