I am trying to get the following sketch to work but i am getting the following code error, can anyone assist?
"'GICR' was not declared in this scope"
// Definition of interrupt names #include < avr/io.h >
// ISR interrupt service routine #include < avr/interrupt.h >
// LED connected to digital pin 13
int ledPin = 13;
// This is the INT0 Pin of the ATMega8
int sensePin = 2;
// We need to declare the data exchange
// variable to be volatile - the value is
// read from memory.
volatile int value = 0;
// Install the interrupt routine.
ISR(INT0_vect) {
// check the value again - since it takes some time to
// activate the interrupt routine, we get a clear signal.
value = digitalRead(sensePin);
}
void setup() {
Serial.begin(9600);
Serial.println("Initializing ihandler");
// sets the digital pin as output
pinMode(ledPin, OUTPUT);
// read from the sense pin
pinMode(sensePin, INPUT);
Serial.println("Processing initialization");
// Global Enable INT0 interrupt
GICR |= ( 1 << INT0);
// Signal change triggers interrupt
MCUCR |= ( 1 << ISC00);
MCUCR |= ( 0 << ISC01);
Serial.println("Finished initialization");
}
I meant to ask where you got the code from.
The #include < avr/interrupt.h >makes me think that it was not intended to run in the normal Arduino environment.
It was written for audrino according to the author.
"For my DCF77 clock project, I need an understanding of handling interrupts with the ATMega8 chip – here’s my sketch.
The ATMega8 provides two pins (2 and 3) which can trigger software interrupts when the attached digital signal changes. You can use this to be “notified” when the external signal changes. Therefore, you do not need to poll the pin periodically – the interrupt routine will be invoked automatically when the specified signal change happens."
I will have a look at the interrupts in detail but i am a rookie and am struggling to get my head around it.