Interrupts and extern variables

I am using a library (hardware.cpp + hardware.h) and have included hardware.h in my sketch. I have placed void interruptsEn(){} and ISR(PCINT2_vect){} in the cpp file in the library, but it does not seem to trigger. The code worked fine when it was still in the .ino sketch. The interrupt is enabled by calling:

void interruptsEn(){
  PCICR |= 0b00000100;  // PORTD

This is called during void setup() in the main sketch. Here is the actual interrupt handler:

ISR(PCINT2_vect) {

  // Has PCINT23 fired (ATN asserted)?
  if ((PIND ^ pinMem) & ATNint) {
    isATN = (PIND & ATNint) == 0;

  // Has PCINT19 fired (SRQ asserted)?
  if ((PIND ^ pinMem) & SRQint) {
    isSRQ = (PIND & SRQint) == 0;

  // Save current state of PORTD register
  pinMem = PIND;


I have determined that interruptsEn() is being successfully called during setup. The ATNint and SRQint constants are declared in the .cpp file only. The bool volatile bool variables isATN and isSRQ are declared in the .cpp file and defined as extern in the sketch. I have confirmed that the pins are changing state, but as far as I can tell, the interrupt is not being triggered. The status of isATN and isSRQ are not getting changed in the sketch.

Do interrupts work in a module (.h/.cpp pair)?

Is it sufficient to define the flag variables as extern in the global scope of the .ino sketch?

The reason I am moving the interrupts to a library is because different boards implement them differently and some do not seem to support interrupts at all. I intend to create a hardware library that implements the appropriate configuration for a given board.

Post your complete code.

Its OK, I figured it out. I forgot to set PCMSK.