Hi gavinremme,
Thank you! So can D11 now be used with attachInterrupt()?
The Non Maskable Interrupt (NMI) isn't used by the attachInterrupt() function, as it's usually employed as an high priority (second only to reset) interrupt, in order to handle emergency hardware fault conditions. Nevertheless it can be used as an additional interrupt.
In the absence of a specific NMI attachInterrupt() function, it's necessary to use register manipulation instead.
How would I enable other pins not setup to be used as interrupts besides the NMI to act as interrupts, like PA10/EXTINT[10]? Just change the 8 to a 10, like this? PORT->Group[PORTA].PINCFG[10].bit.INEN = 1;
Ok, looking at the MKRZero's "variant.cpp" file, I now see what you mean. Only some of the board's pins are configured for interrupts.
I was using a custom SAMD21 board with old Arduino core code to test some interrupt code. In the past it was possible to configure two pins with the same interrupt channel and get them to call the same interrupt function. In the lastest Arduino core code this doesn't work. I'm currently looking at finding a solution.
In the meantime it's possible to get interrupt functionality out of D12, by going the the MKRZero's "variant.cpp" located (on my Windows machine) at:
C:\Users\Computer\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.6\variants\mkrzero
and changing the entry for D12 to:
{ PORTA, 9, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL ), ADC_Channel17, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_9 }, // SCL: SERCOM2/PAD[1]
This will enable interrupt channel EXTINT[9] on D12. You should also be able to obtain interrupts on pins: D0, D1, D4, D5, D6, D7, D8, D9, A3 & A4 by default.
What file contains the register address definitions? How did you know specifically to use EIC_NMICTRL_NMISENSE_RISE for example. Basically I'd like to be able to do this myself in the future.
An explanation of how to access the SAMD21 resgister definitions is provided on post #3 of the following thread on the Arduino Zero forum: Addressing SAM D21 ADC - Arduino Zero - Arduino Forum.
The register definition files can be used in conjuction with the SAMD21 datasheet and board schematic. I normally use a simple editor like Notepad++ to view the register definitions then cut 'n' paste them into a sketch on the Arduino IDE.