Lecture 8
Lecture 8
Lecture 8
Interrupt Subsystem
Interrupt Theory
Unscheduled, higher
priority events are
handled by Interrupt
system.
Upon Interrupt MC will
complete the current
instruction and then jump
to Interrupt Service
Routine (ISR).
Each interrupt has its own
ISR.
After completing ISR MC
will resume from it left off
before the interrupt.
Interrupt Sources
MyISRHandler:
; ISR code to execute here
reti
“reti” has the dual function of exiting the ISR, and automatically re-enabling
the Global Interrupt Enable bit. This happens inside the C version too when
the function returns, we just don't see it normally.
‘C’ definition
Code:
#include <avr/interrupt.h>
ISR({Vector Source}_vect)
{
// ISR code to execute here
}
E.g. vector source could be INT0, INT1 or
INT2 for external Interrupts.
I-bit
I-bit: sei, which SEts the I flag
cli, which CLears the I flag
Code:
sei ; Enable Global Interrupts