Hi everyone!
I've been reading over this thread http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1259918394/15 on how to implement a 3rd "software" interrupt,
I am attempting to do the same thing on my Uno using Pin 11 - I have read through the data sheet specifically chapters 11 and 12 and have come up with the following code:
#include <avr/interrupt.h>
#include <avr/io.h>
void setup() {
pinMode(11, INPUT);
Serial.begin(9600);
PCICR |= (1 << PCIE1);
PCMSK1 |= (1 << PCINT11);
}
volatile int print_flag = 0;
ISR(PCINT2_vect)
{
print_flag = 3;
}
ISR(PCINT0_vect)
{
print_flag = 1;
}
ISR(PCINT1_vect)
{
print_flag = 2;
}
void loop()
{
if(print_flag == 1)
{
Serial.println("interrupt on pcint 0");
print_flag = 0;
}
else if (print_flag == 2)
{
Serial.println("interrupt on pcint 1");
print_flag = 0;
}
else if (print_flag == 3)
{
Serial.println("interrupt on pcint 2");
print_flag = 0;
}
}
As far as I can tell from the data sheet this is correct though it doesn't appear to be working,
I tried the Pin 5 example and it works perfectly - any pointers in the right direction would be much appreciated
Thanks,
Dave