#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/wdt.h>
EMPTY_INTERRUPT(ADC_vect);
EMPTY_INTERRUPT(PCINT0_vect);
EMPTY_INTERRUPT(WDT_vect);
void Sleep() {
noInterrupts(); //Before Sleep Enable
MCUSR = 0; //Clear Flags
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // Select Sleep Mode
sleep_enable();
WDTCR = (1 << WDCE) | (1 << WDE); // Enable WDT change
WDTCR = 0;
wdt_reset();
MCUCR = bit(BODS) | bit(BODSE); // turn on brown-out enable select
MCUCR = bit(BODS); // this must be done within 4 clock cycles of above
interrupts(); //
sleep_cpu();
}
const byte ledPin=1;
void setup() {
MCUSR = 0;
WDTCR = (1 << WDCE) | (1 << WDE); // Enable WDT change
WDTCR = 0;
pinMode(ledPin,OUTPUT);
}
void loop() {
digitalWrite(ledPin,HIGH);
delay(500);
digitalWrite(ledPin,LOW);
delay(500);
Sleep();
}
keeps on waking
but with the two BODS lines commented out, the attiny85 sleeps properly.
brownout enabled 1.8v in bootloader.
anyone know why this would happen?
thanks