Hardware Reference
In-Depth Information
6.2.6 Interrupt Vector
The term interrupt vector refers to the starting address of the interrupt service routine.
In general, interrupt vectors are stored in a table called an interrupt-vector table. The start-
ing address of each entry (holds one interrupt vector) in the interrupt vector table is called the
vector address . The interrupt-vector table is fixed for some microprocessors and may be relo-
cated for other microprocessors.
The CPU needs to determine the interrupt vector before it can provide service. One of the
following methods can be used by a microprocessor or microcontroller to determine the inter-
rupt vector:
1. Predefined . In this method, the starting address of the service routine is predefined
when the microcontroller is designed. The processor uses a table to store all the
interrupt service routines. The Intel 8051 microcontrollers use this approach. Each
interrupt is allocated the same number of bytes to hold its service routine. The Intel
8051 allocates eight words to each interrupt service routine. When the service routine
requires more than eight words, the solution is to place a jump instruction in the
predefined location to jump to the actual service routine.
2. Fetch the vector from a predefined memory location . In this approach, the interrupt
vector of each interrupt source is stored at a predefined location in the interrupt-
vector table, where the microprocessor can get it directly. The Freescale HCS12 and
most other Freescale microcontrollers use this approach.
3. Execute an interrupt acknowledge cycle to fetch a vector number in order to locate
the interrupt vector . During the interrupt acknowledge cycle, the microprocessor
performs a read bus cycle, and the external I/O device that requested the interrupt
places a number on the data bus to identify itself. This number is called the interrupt-
vector number . The CPU can figure out the starting address of the interrupt service
routine by using this number. The CPU needs to perform a read cycle in order to
obtain it. The Freescale 68000 and Intel x86 family microprocessors support this
method. The Freescale 68000 family of microprocessors also uses the second method.
This method is not used by microcontrollers because of the incurred latency.
6.2.7 Interrupt Programming
Interrupt programming deals with how to provide service to the interrupt. There are three
steps in interrupt programming.
Step 1
Initialize the interrupt-vector table. (This step is not needed for microprocessors that have
predefined interrupt vectors.) This can be done by using the assembler directive org (or its
equivalent) as follows:
org
$xxxx
; xxxx is the vector table address
dc.w
service_1
; store the starting address of interrupt source 1
dc.w
service_2
;
.
.
.
dc.w service_n
where service_i is the starting address of the service routine for interrupt source i . The
HCS12 uses this method to set up interrupt vectors. The assembler syntax and the number of
bytes needed to store an interrupt vector on your particular microcontroller may be different.
 
Search WWH ::




Custom Search