PIC Interrupts vs. Polling

Project Info
Author: Chris
Difficulty: Easy-Medium
Time Invested: 1 Hour

Take a look at the above
tutorials before continuing
to read this tutorial.
           After you've been studying and learning about embedded systems, microcontrollers and low level programming for a while, one concept you will undoubtedly cross is the topic of interrupts. Interrupts are used to interrupt the main program cycle to perform a quick and higher priority task so they are typically used when more than 1 input and output exists.
           This tutorial will use a simple example to show you how to include an externally generated interrupt to tell the PIC to run a higher priority task. Since this tutorial is writen for students the part count will be kept low.

PIC Interrupts vs. Polling - Demonstration

PIC Interrupts vs Polling - Setup

Purpose & Overview of this project
           The goal of this tutorial is to build a system that has two types of outputs. One output will be the main program that flashes LEDs in a back and forth 'knight-rider' fashion. The second output will be triggered by an interrupt and should flash all the LEDs on and off a few times before exiting back to the main program.
           In order to generate the interrupt, a standard push-button will be used. When the button is pushed, the PIC 18F452 microcontroller will sense the state change (from 5v to 0v) and issue a hardware interrupt to the software. The software will then pause the main program, execute the interrupt routine and return to the same spot in the main program.