next up previous
Next: Output Compare Interrupts Up: Output Compare Interrupts Previous: Output Compare Interrupts

What are Interrupts?

A program is a list of instructions that the micro-controller executes in a sequential manner. A hardware event is something that happens in the micro-controller's hardware. An example of such an event is the RESET that occurs when pin 9 on the MicroStamp11 is set low. Other hardware events are tied to the real-time clock and certain input lines on the MicroStamp11. Still other hardware events can be used to provide more complex processing (such as parity checking) of frames transmitted or received by the SCI or SPI subsystems.

As a specific example, let's consider an output compare event. In the MicroStamp11, output compare events are tied to a 16-bit hardware register (also called a timer) with the logical name TCNT. This register is incremented at a rate that can be specified by the programmer. When the value of TCNT equals the value stored in another output compare register, then an output compare event occurs and the MicroStamp11 responds by issuing an output compare interrupt.

So what is an interrupt. An interrupt forces the micro-controller's program counter to jump to a specified address in memory. This special memory address is called the interrupt vector. A special function known as an interrupt service routine or ISR is usually installed at the interrupt vector. So the effect of the interrupt is to force program execution to jump to the ISR. When the ISR is done executing, the micro-controller usually returns to the original program it was executing when the interrupt was issued. So an interrupt allows the micro-controller to temporarily interrupt the execution of a program in order to handle an important hardware event. This control flow is illustrated in figure 31.

Figure 31: Interrupt Control Flow

Interrupt service routines are used to execute extremely important segments of code in response to critical exigent events. In an automotive system, for example, we may have a single micro-controller supervising the operation of various systems on the car's dashboard. Usually this micro-controller would be concerned with making sure that the electronic gauges on the ash are displaying the correct information. If, however, the car is in a collision, then these display functions are much less important than the deployment of an airbag. So when this "collision" event occurs, we would want our micro-controller to interrupt its usual tasks to deploy the airbag.

In our case, of course, our hardware events are not as dramatic as "deploy airbag". What type of hardware events we are interested in? You've already used some of these events. As mentioned above, setting pin 9 (RESET) low generates a hardware event that causes the micro-controller to restart itself. When pin 9 goes low, it generates a hardware interrupt that force program execution to jump to the interrupt vector 0xFFFE. This memory location is the default starting address defined in vector.c for your program. So forcing pin 9 low, essentially restarts your program.

There are however a host of other hardware events that can generate interrupts. A table of some of these interrupts and their associated interrupt vectors will be found below.

interrupt vector interrupt source
0xFFFE Power on, Reset
0xFFFA Watchdog timer failure (COP)
0xFFF0 real time interrupt (RTIF)
0xFFEE timer input capture 1, (IC1)
0xFFEC timer input capture 2, (IC2)
0xFFEA timer input capture 3, (IC3)
0xFFE8 timer output compare 1, (OC1)
0xFFE6 timer output compare 2, (OC2)
0xFFE4 timer output compare 3, (OC3)
0xFFE2 timer output compare 4, (OC4)
0xFFE0 timer output compare 5, (OC5)
0xFFDE timer overflow (TOF)
0xFFD8 SPI serial transfer complete (SPIF)
0xFFD6 SCI events (RDRF, TDRE)
0xFFF8 illegal opcode trap
0xFFF6 software interrupt (SWI)

next up previous
Next: Output Compare Interrupts Up: Output Compare Interrupts Previous: Output Compare Interrupts
Bill Goodwine 2002-09-29