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
Non-ConfidentialPDF file icon PDF versionARM DUI0471M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.