Interrupt response time, Atmega128(l) – Rainbow Electronics ATmega128L User Manual
Page 15
15
ATmega128(L)
2467B–09/01
Interrupt Response Time
The interrupt execution response for all the enabled AVR interrupts is 4 clock cycles
minimum. After 4 clock cycles, the program vector address for the actual interrupt han-
dling routine is executed. During this 4-clock cycle period, the Program Counter is
pushed onto the Stack. The vector is normally a jump to the interrupt routine, and this
jump takes 3 clock cycles. If an interrupt occurs during execution of a multi-cycle instruc-
tion, this instruction is completed before the interrupt is served. If an interrupt occurs
when the MCU is in sleep mode, the interrupt execution response time is increased by 4
clock cycles. This increase comes in addition to the start-up time from the selected
sleep mode.
A return from an interrupt handling routine takes 4 clock cycles. During these 4-clock
cycles, the Program Counter (2 bytes) is popped back from the Stack, the Stack Pointer
is incremented by 2, and the I-bit in SREG is set.
Assembly Code Example
sei
; set global interrupt enable
sleep ; enter sleep, waiting for interrupt
; note: will enter sleep before any pending
; interrupt(s)
C Code Example
_SEI(); /* set global interrupt enable */
_SLEEP(); /* enter sleep, waiting for interrupt */
/* note: will enter sleep before any pending interrupt(s) */