Basic understanding of microcontroller interrupts

Earlier I’ve made a mistake by referring this tutorial to first AVR family microcontrollers like Atmega8/16/32/64/128. But AVR is being continuously changed with various new tweaks and updates like enhanced pin control or different register names. Since now tutorial will be based on Atmega328 microcontroller which is popular in Arduino boards. So you’ll be able to test all code examples on Arduino as it can serve as general purpose AVR test board with no problem. Understanding Interrupts Probably you won’t be able to find a microcontroller without interrupt capability. These are essential attributes of any modern microcontroller or processor. They may seem confusing and tricky at first glance, but during the time you will find out that normal MCU operation is impossible without interrupts. Interrupts can be compared to real life events. Look around – all your activities are full of them. For instance, you are reading this tutorial and find it interesting, so you are all in it. But suddenly your cell phone rings. What do you do? You remember the last stroke you’ve read and answered the phone.… Continue reading

How to program external interrupts on AVR

Daniel has sent us a link on his newly prepared AVR ATmega168 Interrupt Routine programming. Programming microcontrollers without interrupts is unimaginable because that’s what microcontrollers actually are designed for – to process various interrupts including external events, timers, data transfer. All well designed programs do these tasks with help of interrupts. In this tutorial there is a smooth line up of things you need to know before you start programming external interrupts. As you know MCU can trigger interrupt on various pin change conditions like transition from low to high state and vice versa, or on any change, or simply when pin is low. So tutorial will explain how to set register values for your wanted interrupt conditions and what cautions has to be taken care off to avoid common issues. Tutorial is filled with several code examples to get started instantly. Continue reading