Skip to content

attachInterrupt() should clear EIC INTFLAG or prior events will cause an interrupt #348

Open
@mweber-ovt

Description

@mweber-ovt

Consider the following pseudocode:
attachInterrupt()....enable interrupts on a pin on falling edge
...
ISR: deal with an interrupt and clear INTFLAG
...
detachInterrupt()...disable interrupt on the pin
...
there is a falling edge on the pin while interrupts are disabled
...
attachInterrupt()...enable interrupts again

An interrupt will be generated, even if the interrupt flag was cleared in the ISR!

This doesn't happen if the interrupt flag is cleared immediately before attachInterrupt() is called:
e.g. for EXTINT[6]
REG_EIC_INTFLAG = EIC_INTFLAG_EXTINT6; // Clear the EXTINT6 flag

It seems to make sense to modify attachInterrupt() to clear the interrupt flag before enabling the interrupt, and/or add a function to clear the interrupt that doesn't require the user to go into the spec sheet and Google and figure everything out by themselves.

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