Technical information

AN2216/D
CodeWarrior Linker
MOTOROLA MC9S12DP256 Software Development Using Metrowerk’s Codewarrior 17
The VECTORS segment must be allocated to the correct memory address in
the linker command file, as shown in Figure 17. In addition, the ENTRIES
command must be used to ensure that the table is included. As there are no
direct references to the vector table in the code, it would otherwise be
'optimised' and removed.
SECTIONS
/* flash, RAM, EEPROM etc */
VECTOR_TABLE = READ_ONLY 0xFF8C TO 0xFFFF; /* Vector Table address */
END
PLACEMENT
/* Placement of code */
VECTORS INTO VECTOR_TABLE; /* Placement of vector_table */
END
ENTRIES
vector_table
END
Figure 17. Example Linker Command File for Manual Vector Table
Automatic Interrupt
Vector Entry
Generation
As a much easier alternative to the manual method, the linker can create
interrupt vector addresses automatically. This is done using the VECTOR
instruction in the linker command file. The array of constant function pointers
used for the manual method is not required.
VECTOR 0 _Startup
VECTOR 38 CAN0_ReceiveISR
Figure 18. Example of Linker Vector Command Block
The number following VECTOR instruction is used by the linker to calculate the
vector address. For vector number 'n', the address is given by $FFFE
2*n.
Thus the address of vector 38 in the example in Figure 18 is $FFFE
$4C =
$FFB2. Vector 0 is the reset vector at $FFFE and _Startup is the default
Codewarrior start-up routine. The VECTOR instructions are placed at the end
of the linker command file. The ENTRIES command block is no longer required
for vector entries when this method is used.