Pin change interrupts on arbitrary pins?

Hi, I am trying to understand the pin change interrupts that are available on Arduino.

From the AttachInterrupt docs, I see "Most Arduino boards have two external interrupts: numbers 0 (on digital pin 2) and 1 (on digital pin 3).". Yet the Atmega328 data sheet specifies PCINTxx values for nearly every pin. So from that, it would seem I could get an interrupt on any pin

What accounts for this difference in docs? And can I actually put an ISR on any pin? (Is it just that I have to do it manually for the others??)

afaik, only 2 pins for interrupts on 8/168/328 arduinos, however, more pins are available on the mega based boards. you would need to hardcode the interrupts, and i'm not sure if doing that would break any other functions.

something like this worked for me:

ISR(PCINT0_vect) {
  …
}

Setup() {
  //disable interrupts
  cli();
  
  //setup digital pin #8 pin-change interrupt (see datasheet)
  PCICR |= (1<<PCIE0); 
  PCMSK0 |= (1<<PCINT0);
 
  //enable interrupts
  sei();
}

maniacbug:
From the AttachInterrupt docs, I see "Most Arduino boards have two external interrupts: numbers 0 (on digital pin 2) and 1 (on digital pin 3).". Yet the Atmega328 data sheet specifies PCINTxx values for nearly every pin. So from that, it would seem I could get an interrupt on any pin

What accounts for this difference in docs?

"external interrupts" versus "pin change interrupts".

"External interrupts" get their own interrupt vector and have extended functionality (hardware support for LOW, RISING, FALLING, CHANGE). RISING, FALLING, and CHANGE do not work if the processor clock is stopped (deeper sleep modes).

"Pin change interrupts" have one vector per port (up to eight pins assigned to one vector) and have very basic functionality (hardware support for CHANGE). Pin change interrupts always work; even in the deepest sleep modes.

And can I actually put an ISR on any pin? (Is it just that I have to do it manually for the others??)

Yes. Examples...

@JimEli's post above.
http://www.arduino.cc/playground/Main/PinChangeInt
http://www.arduino.cc/playground/Main/PcInt
http://www.google.com/search?q=pin+change+interrupt+site:arduino.cc%2Fforum

Totally get it now. Thanks! You have been very helpful to me today :slight_smile: