Die zwei Methoden unterscheiden sich nur beim Handling des SE-Bit. Bei der Methode sleep_cpu() muss durch den Code sichergestellt werden, dass zuvor das SE-Bit gesetzt wird und nach dem Aufwachen der CPU das SE-Bit wieder gelöscht wird.
Microcontroller with xKB of programable memory:
Attiny13 = Microcontroller with 1KB
Attiny25 = Micocontroller with 2KB
Attiny45 = Microcontroller with 4KB
Attiny85 = Microcontroller with 8KB
CPU-Geschwindigkeit:
Attiny13/13A: default: 1,2Mhz (Fuse bit set: CKDIV8)
Attiny25/45/85: default: 1Mhz (Fuse bit set: CKDIV8)
max: 20MHz
Anzahl der Pins: 8Pin(s)
Anzahl der Ein-/Ausgänge: 6I/O(s)
Embedded-Schnittstelle: I2C, SPI
DC Current per I/O Pin: 40.0 mA
DC Current VCC and GND Pins: 200.0 mA
Pinout
ISP Programming
Sleep Modes
/*
* The 5 different modes are:
* SLEEP_MODE_IDLE -the least power savings
* SLEEP_MODE_ADC
* SLEEP_MODE_PWR_SAVE
* SLEEP_MODE_STANDBY
* SLEEP_MODE_PWR_DOWN -the most power savings
*/
set_sleep_mode(SLEEP_MODE_IDLE);
sleep_enable(); // enables the sleep bit in the mcucr register
sleep_cpu(); // here the device is actually put to sleep
// -------------------------------------------------
// THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP
// -------------------------------------------------
sleep_disable(); // disable sleep...
ISR needed for sleep to not reset program after interrupt
Every PCINTx will rise PCINT0_vect
Typically global variables are used to pass data between an ISR and the main program. To make sure variables shared between an ISR and the main program are updated correctly, declare them as volatile.
GIMSK |= (1 << INT0); // Enable external Interrupt
MCUCR &= (0 << ISC01); // The low level of INT0
MCUCR &= (0 << ISC00); // generates an interrupt request