5.31 Writing the exception table for ARMv6-M and ARMv7-M profiles

The easiest way to populate the vector table is to use a scatter file to place a C array of function pointers at memory address 0x0.

You can use the C array to configure the initial stack pointer, image entry point and the addresses of the exception handlers, see the following example.

Note

Some features shown in this example are not available in ARMv6-M. To maintain alignment you must reserve the space by entering 0 in the vector table.

Example C structure for exception handlers

/* Filename: exceptions.c */
typedef void(* const ExecFuncPtr)(void);
/* Place table in separate section */
#pragma arm section rodata="exceptions_area" 
ExecFuncPtr exception_table[] = {
    (ExecFuncPtr)&Image$$ARM_LIB_STACKHEAP$$ZI$$Limit, 
                /* Initial Stack Pointer, from linker-generated symbol */
    (ExecFuncPtr)&__main,         /* Initial PC, set to entry point    */
    &NMIException,
    &HardFaultException,
    &MemManageException,          /* ARMv7-M only (0 for ARMv6-M)      */
    &BusFaultException,           /* ARMv7-M only (0 for ARMv6-M)      */
    &UsageFaultException,         /* ARMv7-M only (0 for ARMv6-M)      */
    0, 0, 0, 0,                   /* Reserved */
    &SVCHandler,                  /* Only available with OS extensions */
    &DebugMonitor,                /* ARMv7-M only (0 for ARMv6-M)      */
    0,                            /* Reserved */
    &PendSVC,                     /* Only available with OS extensions */
    (ExecFuncPtr)&SysTickHandler, /* Only available with OS extensions */
    /* Configurable interrupts start here...*/
    &InterruptHandler,
    &InterruptHandler,
    &InterruptHandler
    /*
    :
    */
};
#pragma arm section
Related concepts
5.29 Vector table for ARMv6-M and ARMv7-M profiles
5.30 Vector Table Offset Register (ARMv7-M only)
Related information
Information about scatter files
Non-ConfidentialPDF file icon PDF versionARM DUI0471K
Copyright © 2010-2014 ARM. All rights reserved.