6.5.2. Installing the handlers at reset

If your application does not rely on the debugger or debug monitor to start program execution, you can load the vector table directly from your assembly language reset (or startup) code.

If your ROM is at location 0x0 in memory, you can have a branch statement for each vector at the start of your code. This could also include the FIQ handler if it is running directly from 0x1C (see Interrupt handlers).

Example 6.2 shows code that sets up the vectors if they are located in ROM at address zero. You can substitute branch statements for the loads.

Example 6.2. 

Vector_Init_Block
                LDR    pc, Reset_Addr
                LDR    pc, Undefined_Addr
                LDR    pc, SVC_Addr
                LDR    pc, Prefetch_Addr
                LDR    pc, Abort_Addr
                NOP                     ;Reserved vector
                LDR    pc, IRQ_Addr
                LDR    pc, FIQ_Addr

Reset_Addr      DCD    Start_Boot
Undefined_Addr  DCD    Undefined_Handler
SVC_Addr        DCD    SVC_Handler
Prefetch_Addr   DCD    Prefetch_Handler
Abort_Addr      DCD    Abort_Handler
                DCD    0                ;Reserved vector
IRQ_Addr        DCD    IRQ_Handler
FIQ_Addr        DCD    FIQ_Handler

You must have ROM at location 0x0 on reset. Your reset code can remap RAM to location 0x0. Before doing this, it must copy the vectors (and the FIQ handler if required) down from an area in ROM into the RAM.

In this case, you must use an LDR pc instruction to address the reset handler, so that the reset vector code can be position independent.

Example 6.3 copies down the vectors given in Example 6.2 to the vector table in RAM.

Example 6.3. 

    MOV        r8, #0
    ADR        r9, Vector_Init_Block
    LDMIA      r9!,{r0-r7}           ;Copy the vectors (8 words)
    STMIA      r8!,{r0-r7}
    LDMIA      r9!,{r0-r7}           ;Copy the DCD'ed addresses
    STMIA      r8!,{r0-r7}           ;(8 words again)

Alternatively, you can use the scatter-loading mechanism to define the load and execution address of the vector table. In that case, the C library copies the vector table for you (see Chapter 2 Embedded Software Development).

Copyright © 2002-2006 ARM Limited. All rights reserved.ARM DUI 0203G
Non-Confidential