I want to generate interrupts from digital input 0 and digital input 1.
I am already using the hardware interrupts on 2 and 3 so I am trying to implement the pin change interrupts for that port.
This what I did (the two pins are named: CLK2_pin and RST2_pin)
pinMode(CLK2_pin, INPUT); // Make digital 0 (PCINT16/PD0) an input
pinMode(RST2_pin, INPUT); // Make digital 1 (PCINT17/PD1) an input
// Pin change interrupt control register - enables interrupt vectors
// Bit 2 = enable PC vector 2 (PCINT23..16)
// Bit 1 = enable PC vector 1 (PCINT14..8)
// Bit 0 = enable PC vector 0 (PCINT7..0)
PCICR |= (1 << PCIE2);
// Pin change mask registers decide which pins are enabled as triggers
PCMSK2 |= (1 << PCINT16);
PCMSK2 |= (1 << PCINT17);
I also have the other intterupts attached:
attachInterrupt(0, clockAISR, RISING); // attach our interrupt pin to it's ISR CLK
attachInterrupt(1, resetAISR, RISING); // attach our interrupt pin to it's ISR CLK
interrupts(); // we need to call this to enable interrupts
Since I am looking for changes on two pins from the same port I need to check both of those pins in the same ISR
ISR(PCINT2_vect){
...
//digitalRead RST2 to see if it is high then do something
//digitalRead CLK2 to see if it is high then do something
}
So far this is not working. Am I missing something?
}