I wrote this test sketch, which I think will tell you which pins can be used in attachInterrupt():
void setup() {
Serial.begin(9600);
while (!Serial)
;
Serial.println("Check interrupt channels");
}
/*
* function copied from cores/arduino/Interrupts.cpp
*/
static int pin2IrqChannel(int pin) {
/* -------------------------------------------------------------------------- */
/* verify index are good */
if (pin < 0 || pin >= PINS_COUNT) {
return -1;
}
/* getting configuration from table */
auto cfg_irq = getPinCfgs(pin, PIN_CFG_REQ_INTERRUPT);
/* verify configuration are good */
if (cfg_irq[0] == 0) {
return -1;
}
return GET_CHANNEL(cfg_irq[0]);
}
char buf[80];
void loop() {
for (int i = 0; i < 20; i++) {
sprintf(buf, "Pin %d channel %d\n", i, pin2IrqChannel(i));
Serial.print(buf);
}
while (1) {
}
}
On my R4 Nano, it shows:
Check interrupt channels
Pin 0 channel 6
Pin 1 channel 5
Pin 2 channel 0
Pin 3 channel 1
Pin 4 channel -1
Pin 5 channel -1
Pin 6 channel -1
Pin 7 channel -1
Pin 8 channel 9
Pin 9 channel -1
Pin 10 channel -1
Pin 11 channel -1
Pin 12 channel 3
Pin 13 channel 4
Pin 14 channel -1
Pin 15 channel 6
Pin 16 channel 7
Pin 17 channel 2
Pin 18 channel 1
Pin 19 channel 2
(the -1 lines are "not allowed")
Oh! I see. This data is in ...variants/*/pinmux.inc ! My tools didn't see it since it doesn't have a usual source-file extension... (IDE 2 can't find it either.)