Lab 16: Understanding Interrupts
Interrupts are powerful concept in embedded systems for controlling events in a time-critical environment. In a typical embedded system, the embedded processor (microcontroller) is responsible for doing more than one task (but can do only one at a time). For example, let’s say in a programmable digital room thermostat, the microcontroller is assigned to monitor the room temperature, turn the AC or heater ON and OFF, control the LCD display, and respond to any new temperature setting from the user. Out of these the first three tasks are non-time-critical and are executed continuously in sequence one after the other, within the main loop. But when the user presses any button on the setting panel, the microcontroller should be able to read it before the user releases the button. So this is a time-critical event and the microcontroller should stop whatever it is doing and respond to this higher priority event. This is possible through the use of interrupts. This tutorial first describes the interrupt system in general and then illustrates how it is handled in PIC micrcontrollers.