Hi all,
I know this thread is a bit old now, but I was implementing some watchdog/ISR stuff the other day and had to use a technique which reminded me of this thread.
AVR ISR reference:
http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.htmlI copied my code from post #12 and updated it so that the ISR is
NAKED. This tells the compiler to create the ISR with no prologue or epilogue code. I thought that the additional code to save state might be slowing down our wakeup test. [The OSCCAL=0xFF we came up with earlier was also added to the code.]
My result:
3.120uS (For newcomers that's time to startup from power-down sleep and toggle a pin. The previous best we got to was 4.0uS).
Note you need to add your own return instruction to a NAKED ISR.
ISR(INT1_vect, ISR_NAKED)
{
pinOff;
reti();
}
Initially I tried declaring it as an EMPTY_INTERRUPT and putting the pin toggle in the main loop, but this was actually slower than the NAKED version - I assume because the EMPTY version jumps back to the main loop before flipping the pin, where the NAKED one flips the pin first, then jumps back.
I also played with the pinOff macro, as in hindsight that is a read-modify-write process, but making it a direct write didn't seem to help the time any.
A small step but thought it was worth letting you guys know