I've got an AT-Tiny85 processor setup to sleep, wake up when a button is pressed, then go back to sleep.
I'm testing the sleep current by powering the board through a 100K resistor, then measuring the voltage drop.
At 5 volts, the board stabilizes at 0.046 volts (across the resistor) which is 0.46 microamperes.
My two questions are:
(1) Is my test method valid? (I don't have a micro-amp capable meter)
(2) Is 0.46 uA "good"?
This is what I'm doing to get into sleep mode:
ADCSRA = 0x00; // disable ADC
power_adc_disable(); // power down ADC
power_timer1_disable(); // power down timer 1
power_usi_disable(); // power down USI
MCUCR = _BV(PUD); // disable port pullups
set_sleep_mode (SLEEP_MODE_PWR_DOWN); // set CPU sleep mode
LABEL: // see note below
sleep_enable(); // enable CPU to be powered down
sleep_bod_disable(); // turn off brown-out detector
sleep_cpu(); // power down cpu (all clocks stopped)
// hanging here until button is pressed
// here is where the current measures 0.46 uA
When the button is detected, the ISR does this:
GIMSK = 0x00; // disable hardware INT0
sleep_disable(); // prevent going back to sleep
// main loop does it's thing, then goes back to "LABEL"
Is all this "right", and is there anything else I should be doing (or something I should NOT do?).
... is very likely not necessary. The pin driver has circuitry that automatically manages a pin, for the majority of situations, when the processor is put to sleep.
And, if you use the internal pullups (e.g. for pushbuttons) then disabling all pullups will leave those pins unable to reliably generate a wake interrupt (if that's needed).
Do you have the Brown Out Detector (BOD) enabled through the fuses? If yes then you can squeeze just a bit more out by disabling it just before sleeping.
(Never mind. I now see you are calling sleep_bod_disable.)
Yes, I should have mentioned. There are three I/O pins. One is the pushbutton (externally pulled up with a 100K). The next one is currently unused, and it has a 100K pullup. The last one drives a mosfet gate, and it has a 100 ohm between the pin and the gate, and 100K between the pin and ground.
Software-wise, the DDR for those pins has the bits low (i.e inputs) and the bits on the PORT are low (i.e. no internal pullup).