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.


  1. bryan says:

    love all the ‘n00b concept’ posts.. seriously.. it makes the HAD grow. thanks!

  2. r_d says:

    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.

  3. d says:

    nice title nice post

  4. James says:

    Is terribad a new word? Love it. Might start using it!

  5. fluidic says:

    Interrupts – they do what it says on the tin.

  6. DarkFader says:

    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.

  7. Navic says:

    “Interrupts are powerful. Learn them, love them, use them.” – Awesome line!! Wish it was on a t-shirt, lol!!

  8. It is not ProtoShack.. it is ProtoStack :)

  9. Malikaii says:

    So, is this taking the place of the C# development tutorial for this week? I was looking forward to that.

  10. pall.e says:

    big fan of these beginner concepts post. Keep them coming HAD

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 98,246 other followers