GPS_TIMEPUSE IRQ on ONE v2 bug?

I’m trying to get an IRQ on the GPS_TIMEPULSE event on the Sodaq ONE v2. Now I’m supposed to do with like this:
pinMode(GPS_TIMEPULSE, INPUT); attachInterrupt(digitalPinToInterrupt(GPS_TIMEPULSE), pulse, RISING );
Which does not work.

However, GPS_TIMEPULSE is defined as PIN D17. When I print what is returned from digitalPinToInterrupt, it returns 14.

If I directly set 17 as first parameter to attachInterrupt, it does work. Do I misunderstand the usage of how to set interrupt, or is this a bug?

Vincent

On the AVR platform you need to use the digitalPinToInterrupt() macro, as there are normally only a couple of external interrupt lines available (pin change interrupts use a separate mechanism).

On the SAMD platform almost all of the IO pins support external interrupt, and so you simply specify the pin (17 in the above case). If you are using multiple external interrupts you may need to check which IO pins you use as some share the same interrupt line.

One other thing to note, by default, the change mode (RISING, FALLING, CHANGE) interrupts will not work correctly in sleep mode. This is due to the default clock configuration. These modes require an active clock and the default clock configuration does not keep the source running when in sleep mode. HIGH and LOW will still work.

Thanks Gabriel,

I’ve just used the call w/o the mapping.

However, should digitalPinToInterrupt() not return the correct value, just for the sake of compatibility?

I’m not sure of the background on this. However, the digitalPinToInterrupt() macro on both platforms returns the interrupt number or interrupt line. On the SAMD platform it is possible for up to four IO pins to share the same interrupt line (details can be found in the datasheet).

While the interrupt is simply attached to the interrupt lines, there are other operations which are carried out on the IO pin as well. As there is not a unique relationship between the interrupt lines and the IO pins, this requires that the pin be specified.