I'm trying to get an ATTiny85 to run off a battery. I have it clocked from a 16.384 MHz crystal, with the divide-by-8 fuse set. Vcc is 3.3 volts. Figure 22-7 in the datasheet says that at idle ( set_sleep_mode(SLEEP_MODE_IDLE); sleep_mode();
), it should draw around 300 µA. In actual fact, I see it drawing more like 850 µA. I can't figure out why the power consumption is double expected. I've turned off everything in PRR except for timer0, which I've configured to interrupt every 25 ms. So it should spend the vast majority of its time in the idle state, which is the best I can do given that I still want the timers to count.
The fuses are 0x7f, 0xdf, 0xff.
Here's the code it's running for this test:
#include <Arduino.h>
#include <EEPROM.h>
#include <avr/sleep.h>
#include <avr/power.h>
#define P0 0
#define P1 1
#define P_UNUSED 2
ISR(TIMER0_COMPA_vect) {
// do nothing - just wake up
}
void setup() {
power_adc_disable();
power_usi_disable();
power_timer1_disable();
//PRR = _BV(PRADC) | _BV(PRTIM1) | _BV(PRUSI); // everything off but timer 0.
TCCR0A = _BV(WGM01); // mode 2 - CTC
TCCR0B = _BV(CS02) | _BV(CS00); // prescale = 1024
// xtal freq = 16.384 MHz.
// CPU freq = 16.384 MHz / 8 = 2.048 MHz
// count freq = 2.048 MHz / 1024 = 2000 Hz
OCR0A = 50; // 25 msec per irq
TIMSK = _BV(OCIE0A); // OCR0A interrupt only.
set_sleep_mode(SLEEP_MODE_IDLE);
pinMode(P_UNUSED, INPUT_PULLUP);
pinMode(P0, OUTPUT);
pinMode(P1, OUTPUT);
digitalWrite(P0, LOW);
digitalWrite(P1, LOW);
while(1) { sleep_mode(); }
}
void loop() {}