Hello everyone Im planning on using the Arduino UNO for a project of mine and as im waiting for the order to get shipped I thought I would start on the code. Now I am familiar with interrupts but not with the ATMega 328 found on the Arduino UNO. How do I set up the interrupt ISRs?
According to http://arduino.cc/en/Reference/AttachInterrupt
This is not for a specific ATMega processor
Example
void setup()
{
pinMode(pin, OUTPUT);
attachInterrupt(0, blink, CHANGE);
}
void blink()
{
...
}
but then elsewhere I have found this kind of code for the ATMega8
// Definition of interrupt names
#include < avr/io.h >
// ISR interrupt service routine
#include < avr/interrupt.h >
// Install the interrupt routine.
ISR(INT0_vect) {
....
}
void setup() {
...
// Global Enable INT0 interrupt
GICR |= ( 1 < < INT0);
// Signal change triggers interrupt
MCUCR |= ( 1 << ISC00);
MCUCR |= ( 0 << ISC01);
....
}
Neither of them clear an interrupt flag in the ISR either which is strange
to me. Any tips on the right way todo this?
Thanks
According to http://arduino.cc/en/Reference/AttachInterrupt
This is not for a specific ATMega processor
Example
void setup()
{
pinMode(pin, OUTPUT);
attachInterrupt(0, blink, CHANGE);
}
void blink()
{
...
}
but then elsewhere I have found this kind of code for the ATMega8
// Definition of interrupt names
#include < avr/io.h >
// ISR interrupt service routine
#include < avr/interrupt.h >
// Install the interrupt routine.
ISR(INT0_vect) {
....
}
void setup() {
...
// Global Enable INT0 interrupt
GICR |= ( 1 < < INT0);
// Signal change triggers interrupt
MCUCR |= ( 1 << ISC00);
MCUCR |= ( 0 << ISC01);
....
}
Neither of them clear an interrupt flag in the ISR either which is strange
to me. Any tips on the right way todo this?
Thanks