29
ATmega103(L)
0945G–09/01
Interrupt Handling
The ATmega103(L) has two dedicated 8-bit Interrupt Mask control registers; EIMSK
(External Interrupt Mask register) and TIMSK (Timer/Counter Interrupt Mask register). In
addition, other enable and mask bits can be found in the peripheral control registers.
When an interrupt occurs, the Global Interrupt Enable I-bit is cleared (zero) and all inter-
rupts are disabled. The user software can set (one) the I-bit to enable nested interrupts.
The I-bit is set (one) when a Return from Interrupt instruction (RETI) is executed.
When the Program Counter is vectored to the actual interrupt vector in order to execute
the interrupt handling routine, hardware clears the corresponding flag that generated the
interrupt. Some of the interrupt flags can also be cleared by writing a logical “1” to the
flag bit position(s) to be cleared.
If an interrupt condition occurs when the corresponding interrupt enable bit is cleared
(zero), the interrupt flag will be set and remembered until the interrupt is enabled or the
flag is cleared by software.
If one or more interrupt conditions occur when the global interrupt enable bit is cleared
(zero), the corresponding interrupt flag(s) will be set and remembered until the global
interrupt enable bit is set (one), and will be executed by order of priority.
Note that external level interrupt does not have a flag and will only be remembered for
as long as the interrupt condition is active.
Note that the Status Register is not automatically stored when entering an interrupt rou-
tine or restored when returning from an interrupt routine. This must be handled by
software.
External Interrupt Mask
Register – EIMSK
• Bits 7..4 – INT7 - INT4: External Interrupt Request 7 - 4 Enable
When an INT7 - INT4 bit is set (one) and the I-bit in the Status Register (SREG) is set
(one), the corresponding external pin interrupt is enabled. The Interrupt Sense Control
bits in the External Interrupt Control Register (EICR) define whether the external inter-
rupt is activated on rising or falling edge or is level-sensed. Activity on any of these pins
will trigger an interrupt request even if the pin is enabled as an output. This provides a
way of generating a software interrupt.
• Bits 3..0 – INT3 - INT0: External Interrupt Request 3 - 0 Enable
When an INT3 - INT0 bit is set (one) and the I-bit in the Status Register (SREG) is set
(one), the corresponding external pin interrupt is enabled. The external interrupts are
always low-level triggered interrupts. Activity on any of these pins will trigger an interrupt
Table 8.
Reset Source Identification
Reset Source
EXTRF
PORF
Watchdog Reset
0
0
Power-on Reset
0
1
External Reset
1
0
Power-on Reset
1
1
Bit
7
6
5
4
3
2
1
0
$39 ($59)
INT7
INT6
INT5
INT4
INT3
INT2
INT1
INT0
EIMSK
Read/Write
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
Initial Value
0
0
0
0
0
0
0
0