2 interrupts, one pin, Nano classic

Hello, I'm looking at some code that is looking at the length of an input pulse on an interrupt pin. Two ISRs are defined, one called on a rising edge, the other on a falling, both attached to the same pin. Is this possible, or will only the second interrupt attachment be retained? A better way to do this would seem to be to have a single ISR triggered by a change that interrogates the input when triggered to determine which way the pin changed. Input gratefully received, thankyou!

No, you can't attach two interrupts to the one pin simultaneously. But you can attach rising interrupt first, wait for the edge and than attach the failing interrupt just in the IRQ routine.
I used this way to measure FREQ and DUTY of the Arduino's PWM signal in this thread.

Yes, why not do that?

There is also the pin change interrupt, but you'll need to track which change is happening. i.e., high -> low or low -> high

Many thanks for this clarification!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.