
Learn How to Communicate 49
opcode—to put aside the processor’s current work and transfer control to the
interrupt service routine. Many of the processor’s registers must be saved in mem-
ory, and lower-priority interrupts must be disabled. So in practice both methods
are used frequently. Interrupts are used when efficiency is paramount or multiple
devices must be monitored simultaneously. Polling is used when the processor
must respond to some event more quickly than is possible using interrupts.
Interrupt Map
Most embedded systems have only a handful of interrupts. Associated with each of
these are an interrupt pin (on the outside of the processor chip) and an ISR. In
order for the processor to execute the correct ISR, a mapping must exist between
interrupt pins and ISRs. This mapping usually takes the form of an interrupt vec-
tor table. The vector table is usually just an array of pointers to functions, located
at some known memory address. The processor uses the interrupt type (a unique
number associated with each interrupt pin) as its index into this array. The value
stored at that location in the vector table is usually just the address of the ISR to be
executed.
*
It is important to initialize the interrupt vector table correctly. (If it is done incorrectly,
the ISR might be executed in response to the wrong interrupt or never executed at
all.) The first part of this process is to create ...