Lecture-5-Interrupts-_-ADC-_1_
Lecture-5-Interrupts-_-ADC-_1_
EMBEDDED SYSTEMS
PROGRAMMING
LECTURE 5 INTERRUPTS & ANALOG INPUT (ADC)
Atmega 328 Pinout
I/O Memory (SFR) Overview
If INT# bit is set (and the SREG I-bit is set), then interrupts are enabled on pin INT#
External Interrupt Flag Register
attach interrupt
void setup() {
pinMode(pin, OUTPUT);
attachInterrupt(0, blink, CHANGE);
}
Arduino Language Support for
External Interrupts
Write Interrupt Service Routine (ISR)
void blink() {
state = !state;
}
deattach
deattachInterrupt(0);
Arduino Macro for Interrupt Vector
•Use ISR Macro to handle interrupt
◦ ISR(EXT_INT0_vect)
{
◦ EIMSK = B00000001
◦ EICRA = B00000011