Skip to content

Unable to use digitalPinToInterrupt with attachInterrupt and detachInterrupt #18

Closed
@per1234

Description

@per1234

We expect to be able to use the attachInterrupt(digitalPinToInterrupt(pin), ISR, mode) syntax, even when the use of digitalPinToInterrupt is not absolutely necessary due to the interrupts having the same numbering as the pins (e.g. SAMD). This allows code to be written that is portable across architectures.

This is not currently possible with Arduino megaAVR Boards. Arduino megaAVR Boards' attachInterrupt was written to take a pin number as the first parameter, then convert the pin number to interrupt number inside attachInterrupt using digitalPinToInterrupt, breaking from the convention established in Arduino AVR Boards.

To make matters more confusing, the attachInterrupt documentation falsely claims:

For Uno WiFiRev.2, Due, Zero, MKR Family and 101 boards the interrupt number = pin number.

The attachInterrupt documentation also specifically says that the attachInterrupt(pin, ISR, mode) syntax is not recommended.


Originally reported at:
http://forum.arduino.cc/index.php?topic=592249

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions