ostaquet / Arduino-Nano-33-IoT-Ultimate-Guide

Arduino Nano 33 IoT - Ultimate guide
MIT License
195 stars 26 forks source link

Available external interrupts #1

Closed mfreema5 closed 4 years ago

mfreema5 commented 4 years ago

I had difficulty tracking down information on which pins can be used with attachInterrupt(), so I thought I'd share what I found. Hopefully it's useful to someone.

Board PIN Internal PIN Interrupt
A2 16 EXTERNAL_INT_0
A3 17 EXTERNAL_INT_1
A6 20 EXTERNAL_INT_4
A7 21 EXTERNAL_INT_5
D2 2 EXTERNAL_INT_2
D3 3 EXTERNAL_INT_3
D9 9 EXTERNAL_INT_9
D10 10 EXTERNAL_INT_10
D11 11 EXTERNAL_INT_11

That information was extracted from github.com/arduino/ArduinoCore-samd/blob/master/variants/nano_33_iot/variant.cpp. Use at your own risk, etc.

Edit: Trials show the analog pins don't seem to work as interrupts.

ostaquet commented 4 years ago

Thanks, very useful!

Added in the doc ;-)

mfreema5 commented 4 years ago

So, it seems I wasn't reading the information on github.com/arduino/ArduinoCore-samd/blob/master/variants/nano_33_iot/variant.cpp quite right. Turns out you need to look at the column labeled Peri.A EIC (EXTINT); entries with an asterisk (*) are available as interrupts.

Corrected table:

Board PIN Internal PIN
A1 15
A5 19
A7 21
D2 2
D3 3
D9 9
D10 10
D11 11

I've tested all these and they do act as interrupts. (At least they do in a simple sketch that does nothing but detect interrupts.)

ostaquet commented 4 years ago

Thanks for the update ;-)