What's the actual difference between edge sensitive and level sensitive interrupts

Its exactlly what is says.

If edge interrupt is set, the ISR will only get fired on falling/rising edge of a pulse. While if level sensitive interrupt (as you say) is set the ISR will get fired everytime there is a low-level/high-level signal on the corresponding pin.

In short, edge interrupt gets fired only on changing edges, while level interrupts gets fired as long as the pulse is low or high.

So if you have low-level interrupt set, MCU will keep executing the ISR as long as the pin is low.


A level sensitive interrupt and an edge sensitive interrupt are actually two quite different things. I'll try to give some general insights that might help you understand how other interrupts work too.

Let's assume that your CPU can execute code in two modes: normal mode, and interrupted mode. To go from normal mode to interrupt mode an interrupt, whatever it is, must happen, while to come back the IRET instruction must be executed. Let's also assume that if an interrupt happens while in interrupt mode it gets somehow saved but it is not immediately serviced, i.e. when in interrupt mode the CPU can not be interrupted.

So what is an interrupt? I would say it is an event: something that happens, a timer overflows, a pin goes low, whatever. The CPU does something to respond to the event then resumes normal execution. What happens if an event occurs while another is being serviced? Usually a bit is set in some register and just after the IRET instruction the CPU is interrupted again, checks which bit is set and executes the correct interrupt service routine.

You might now see why level triggered and edge triggered are two different things: they are two different events. When your ISR on the level triggered interrupt is executed you probably clear the interrupt bit as first thing: if the level stays low the hardware immediately triggers another interrupt that will be serviced just when you are finished with this. In an edge triggered interrupt you need the pin to go high and then low again to trigger the interrupt once more.

I can't think of a meaningful example of when you would need a level triggered interrupt, edge triggered seems much more useful and what you'd usually need anyway.

Tags:

Interrupts