Beginner Concepts: All About AVR Interrupts

Microcontroller interrupts are one of the big tools in our embedded programming arsenal. They make the chip listen for particular events, and once detected they stop what they’re doing and run a separate set of code called and Interrupt Service Routine. We’ve come across two fairly new tutorials on the subject that you should check out if you’re not yet a master on the topic. One is a ProtoShack tutorial on ATmega168 external interrupts, and the other is a Newbie’s Guide to AVR Interrupts by [Dean Camera] (we’ve been a fan of his tutorials for some time). Both cover a range of topics from what interrupts are, to avoiding the common problems of volatile data types and the compiler optimization caveats.

What can you do with interrupts? External interrupts can be used to wake up a project like this LED menorah from sleep mode. Interrupts can be used to monitor a timer for a certain value or an overflow for use in generating a pulse-width modulation signal. The TI Launchpad uses an interval timer interrupt for button debouncing in projects like this code which was ported from an AVR chip. The source for both is available if you wanted to compare how the two differ.

Interrupts are powerful. Learn them, love them, use them.

10 thoughts on “Beginner Concepts: All About AVR Interrupts

  1. Good post.
    I’m sure a lot of us who work with AVRs already know this, but that’s probably why it’s labelled “beginner concepts”.
    In any case, it’s a whole lot more relevant than those terribad C# and Java/Android applications development tutorials were (the latter didn’t so much as mention the NDK, which is what HaD should be most interested in!).
    This is precisely what the programming tutorials should be.

  2. You don’t want to interrupts so much and that long though. It’s great if you have DMA with it.
    I could only write 60KB/s from network to an SD card using interrupts and SPI, which is like w00t. But at least it doesn’t block the main program.

Leave a Reply to DarkFaderCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.