Ich kenne den Tiny13 nicht, habe aber ähnliches mit dem Tiny25 schon
gemacht. Ich verwende dort zur Initialisierung:
1 | sei();
|
2 | // Power-Down Sleep Mode initialisieren
|
3 | set_sleep_mode(SLEEP_MODE_PWR_DOWN); // stromsparend, aufwecken über WD oder INT0
|
4 | sleep_enable(); // Schlafmodus vorbereiten
|
danach an gewünschter Stelle
Das hat jedenfalls prima funktioniert.
Deine diskrete Initialisierung im initSleep() hat ev. das Problem, das
beim Tiny25 im Manual so beschrieben ist:
Bit 5 – SE: Sleep Enable
The SE bit must be written to logic one to make the MCU enter the sleep
mode when the SLEEP instruction is executed. To avoid the MCU entering
the sleep mode unless it is the programmer’s purpose, it is recommended
to write the Sleep Enable (SE) bit to one just before the execution of
the SLEEP instruction and to clear it immediately after waking up.
Das dürfte beim Tiny13 nicht anders sein. Es müsste also das
Sleep-Kommando direkt nach dem SE kommen.