I am using the ATtiny85, ICCAVR(version 7.22C) and AS4.18
The main loop is only to generate a series of pulses until time to stop and delay for about 2 seconds
then resume with the Timer0 interrupt pulse outputs. This is a battery operated application,
so I thought using the 'do nothing' 2 second period , it would be better to use the sleep mode
The existing code works exactly as I need, but would like to explore the sleep mode.
I would like to:
Stop timer0 interrupts
Setup WDT interrupt mode for 2 seconds.
Execute sleep instruction, power down mode.
When WDT interrupt routine executes , re-enable Timer0 interrupts,
continue execution as before, the pulses for a while, then the 2 second delay, which could
include the sleep mode during the 2 second period and this would be the endless loop.
Is this a good way to accomplish this?
ICCAVR: is there any function/library to execute the sleep instruction, or is
inline assembly the way or only way to go?
The tiny85 manual indicates :
"If an enabled interrupt occurs while the MCU is in a sleep mode, the MCU wakes up. The MCU
is then halted for four cycles in addition to the start-up time, executes the interrupt routine, and
resumes execution from the instruction following SLEEP. "
but that the RETI will execute the instruction following the sleep instruction.
I am not clear on what should follow the sleep instruction.
Any clarification or suggestions on implemented this approach?
I did use the sleep mode years ago with a ATtiny 12, but that project and code has long since