In a native avrc program I use the external interrupt 1 as a wake up source from powerdown mode. After setting up stuff and go to sleep I need only to do a task when an interrupt is fired or a reset is performed.
My code looks like the following:
setup stuff. ... gotoSleep();
do task; ...
As i want it to go to sleep mode again it's a good idea to modify the code in the main program like this instead of calling a sleep inside the int routine?
setup stuff. ... gotoSleep(); while(1) gotoSleep();
The program counter register should be returned to the following instruction in the main program and execute forever the loop with the sleep request..
As I have seen I should also re-enable interrupts during an interrupt call cause the complier disables them automatically when executing an interrupt routine.. It looks to me that in a long time it will result in a stack overflow for too much int calls..