attach_interrupt no longer works for external interrupts

Does anyone know how to get the external interrupts working on the 33IOT?
I had a rotary encoder working on the Nano and now that I am using the 33IOT, this no longer works.
I have looked and looked but can find no documentation.
Please help!

Which pin are you using for the interrupt on the Nano 33 IoT?

svance23:
I have looked and looked but can find no documentation.

Yes, there is a problem in general with the documentation not all having been updated to include the new(ish) Nano boards. I'll submit a pull request to update the attachInterrupt() documentation.

I'm using pins D2 and D3 (pins 5 & 6 on the Nano).

This used to work with code much like this...

attachInterrupt(0,intFxn,CHANGE);
attachInterrupt(1,intFxn,CHANGE);

I believe that, on the old Nano, D2 and D3 were hard-wired to extint 0 and 1.

svance23:
I'm using pins D2 and D3 (pins 5 & 6 on the Nano).

I'm not sure what you mean by that, but the pins you can use with attachInterrupt() on the Nano 33 IoT are: 2, 3, 9, 10, 11, 13, 15, A5, A7.

I have submitted a PR to add this documentation (as well as the interrupt pins on the Nano Every, Nano 33 BLE, and Nano 33 BLE Sense) to the attachInterrupt() reference page:

svance23:
This used to work with code much like this...

attachInterrupt(0,intFxn,CHANGE);
attachInterrupt(1,intFxn,CHANGE);

I believe that, on the old Nano, D2 and D3 were hard-wired to extint 0 and 1.

As is documented on the attachInterrupt() reference page, that is a bad idea. You should always use digitalPinToInterrupt to convert between Arduino pins and interrupts. So let's say you wanted to attach an interrupt to pin 2. It would look like this:

attachInterrupt(digitalPinToInterrupt(2),intFxn,CHANGE);

Now, the truth is that on the SAMD boards the interrupt numbers are the same as the pin numbers, so you can do without digitalPinToInterrupt(), but best practices is to still use it, because this makes your code portable to any architecture.

1 Like

Thanks very much! That did the trick.

You're welcome. I'm glad to hear it's working now. Enjoy!
Per