Arduino attachInterrupt() command

The attachInterrupt() command allows the user to specify the interrupt mode as LOW CHANGE RISING FALLING (and HIGH on some Arduinos). RISING FALLING and CHANGE are easy to understand since the interrupt appears to be triggered on the state transition of the interrupt pin.
I am not sure I understand LOW and HIGH. They have to be different from the FALLING and RISING which trigger on the change to call the interrupt routine. Is the interrupt routine repeatedly called and therefore behaves like a loop and executes again and again so long as the input is LOW (or HIGH as the case may be) since the input can be LOW (or HIGH) for extended periods of time? If not, what is it? At this point I am not sure what the difference is between the FALLING and LOW interrupt modes (or RISING and HIGH interrupt modes).
Any explanation will be appreciated since the Arduino reference is not helpful here.

Why not just TEST it? A 220 Ohm resistor in series with a LED and attached to an output pin and ground. Connect the interrupt pin to ground. Program to interrupt on low. In the interrupt code, turn the pin with the led to high. Now connect the interrupt pin to +5 and test again.

Oh, also, in loop(), turn the led off.

Detecting an edge (RISING or FALLING) requires the clock running. In some sleep-modes the clock is not running, edge detection doesn’t work and the processor doesn’t wake up. Level LOW does work in that case.
Caveats: if the level disappears too soon, the processor wakes up but the ISR won’t be executed. If the level persists, the ISR will be executed again.

1 Like

LOW will continually fire the interrupt as long as the pin is held low. FALLING or RISING will only fire the interrupt once at the specified edge.

1 Like

I am just curious to know if ATmega328P's interrupt logic can distinguish whether the interrupt signal is a genuine edge or a noise-spike edge. The legendary 8086's NMI interrupt can differenciate them by ANDing the edge with HIGH.

It can't. A noise edge will trigger too. Do your debounce after the first trigger.

1 Like

Not the AVR chips. The Renesas chips have a noise filter IIRC. EDIT: They do not. I just checked.

1 Like

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