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

The easiest way to populate the vector table is to use a scatter-loading description 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 Example 52.

Note

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

Example 52. 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

Show/hideSee also

Copyright © 2010-2012 ARM. All rights reserved.ARM DUI 0471G
Non-ConfidentialID021412