I'm reading through the CC26xx Driver Library documentation where in the documentation for interrupt.h it says the following for statically configuring the interrupt vector table:
Static registration of interrupt handlers is accomplished by editing the interrupt handler table in the startup code of the application. Texas Instruments provides startup files for each supported compiler ( startup_<compiler>.c
) and these startup files include a default static interrupt vector table. All entries, except ResetISR, are declared as extern
with weak assignment to a default interrupt handler. This allows the user to declare and define a function (in the user's code) with the same name as an entry in the vector table. At compile time, the linker then replaces the pointer to the default interrupt handler in the vector table with the pointer to the interrupt handler defined by the user.
Statically configuring the interrupt table provides the fastest interrupt response time because the stacking operation (a write to SRAM on the data bus) is performed in parallel with the interrupt handler table fetch (a read from Flash on the instruction bus), as well as the prefetch of the interrupt handler (assuming it is also in Flash).
I want to handle SVCalls and according to this paragraph from the documentation I have to define a function with the same name as an entry in the vector table. But when I look in the startup_ccs.c file found in ti/simplelink_cc13x2_26x2_sdk_3_40_00_02/sources/ti/devices/cc13x2_c26x2/startup_files I don't see any names.
I do see an IntDefaultHandler entry with a comment after it saying "// 11 Supervisor Call (SVCall)", but most of the other interrupts also use the IntDefaultHandler. So if that statement in the documentation means I have to define my own IntDefaultHandler function won't I be handling all those other interrupts as well? Also the documentation says that the entries are declared as extern, but in the file I see IntDefaultHandler declared as "static void IntDefaultHandler( void );", so not as an extern.
How do I add my own SVCall handler to this vector table statically? Or is it only possible to do this dynamically?
The code below shows the contents of the startup_ccs.c file.
//***************************************************************************** // // Check if compiler is CCS // //***************************************************************************** #if !(defined(__TI_COMPILER_VERSION__)) #error "startup_ccs.c: Unsupported compiler!" #endif #include "../inc/hw_types.h" #include "../driverlib/setup.h" //***************************************************************************** // //! Forward declaration of the reset ISR and the default fault handlers. // //***************************************************************************** void ResetISR( void ); static void NmiSR( void ); static void FaultISR( void ); static void IntDefaultHandler( void ); extern int main(void); //***************************************************************************** // //! The entry point for the application startup code and device trim fxn. // //***************************************************************************** extern void _c_int00(void); //***************************************************************************** // // CCS: Linker variable that marks the top of the stack. // //***************************************************************************** extern unsigned long __STACK_END; //! The vector table. Note that the proper constructs must be placed on this to //! ensure that it ends up at physical address 0x0000.0000 or at the start of //! the program if located at a start address other than 0. // //***************************************************************************** #pragma DATA_SECTION(g_pfnVectors, ".intvecs") void (* const g_pfnVectors[])(void) = { (void (*)(void))((unsigned long)&__STACK_END), // 0 The initial stack pointer ResetISR, // 1 The reset handler NmiSR, // 2 The NMI handler FaultISR, // 3 The hard fault handler IntDefaultHandler, // 4 Memory Management (MemManage) Fault IntDefaultHandler, // 5 The bus fault handler IntDefaultHandler, // 6 The usage fault handler 0, // 7 Reserved 0, // 8 Reserved 0, // 9 Reserved 0, // 10 Reserved IntDefaultHandler, // 11 Supervisor Call (SVCall) IntDefaultHandler, // 12 Debug monitor handler 0, // 13 Reserved IntDefaultHandler, // 14 The PendSV handler IntDefaultHandler, // 15 The SysTick handler //--- External interrupts --- IntDefaultHandler, // 16 AON edge detect IntDefaultHandler, // 17 I2C IntDefaultHandler, // 18 RF Core Command & Packet Engine 1 IntDefaultHandler, // 19 PKA Interrupt event IntDefaultHandler, // 20 AON RTC IntDefaultHandler, // 21 UART0 Rx and Tx IntDefaultHandler, // 22 AUX software event 0 IntDefaultHandler, // 23 SSI0 Rx and Tx IntDefaultHandler, // 24 SSI1 Rx and Tx IntDefaultHandler, // 25 RF Core Command & Packet Engine 0 IntDefaultHandler, // 26 RF Core Hardware IntDefaultHandler, // 27 RF Core Command Acknowledge IntDefaultHandler, // 28 I2S IntDefaultHandler, // 29 AUX software event 1 IntDefaultHandler, // 30 Watchdog timer IntDefaultHandler, // 31 Timer 0 subtimer A IntDefaultHandler, // 32 Timer 0 subtimer B IntDefaultHandler, // 33 Timer 1 subtimer A IntDefaultHandler, // 34 Timer 1 subtimer B IntDefaultHandler, // 35 Timer 2 subtimer A IntDefaultHandler, // 36 Timer 2 subtimer B IntDefaultHandler, // 37 Timer 3 subtimer A IntDefaultHandler, // 38 Timer 3 subtimer B IntDefaultHandler, // 39 Crypto Core Result available IntDefaultHandler, // 40 uDMA Software IntDefaultHandler, // 41 uDMA Error IntDefaultHandler, // 42 Flash controller IntDefaultHandler, // 43 Software Event 0 IntDefaultHandler, // 44 AUX combined event IntDefaultHandler, // 45 AON programmable 0 IntDefaultHandler, // 46 Dynamic Programmable interrupt // source (Default: PRCM) IntDefaultHandler, // 47 AUX Comparator A IntDefaultHandler, // 48 AUX ADC new sample or ADC DMA // done, ADC underflow, ADC overflow IntDefaultHandler, // 49 TRNG event IntDefaultHandler, // 50 Combined event from Oscillator control IntDefaultHandler, // 51 AUX Timer2 event 0 IntDefaultHandler, // 52 UART1 combined interrupt IntDefaultHandler // 53 Combined event from battery monitor }; //***************************************************************************** // //! This is the code that gets called when the processor first starts execution //! following a reset event. Only the absolutely necessary set is performed, //! after which the application supplied entry() routine is called. Any fancy //! actions (such as making decisions based on the reset cause register, and //! resetting the bits in that register) are left solely in the hands of the //! application. // //***************************************************************************** void ResetISR(void) { // // Final trim of device // SetupTrimDevice(); // // Jump to the CCS C Initialization Routine. // __asm(" .global _c_int00\n" " b.w _c_int00"); // // If we ever return signal Error // FaultISR(); } //***************************************************************************** // //! This is the code that gets called when the processor receives a NMI. This //! simply enters an infinite loop, preserving the system state for examination //! by a debugger. // //***************************************************************************** static void NmiSR(void) { // // Enter an infinite loop. // while(1) { } } //***************************************************************************** // //! This is the code that gets called when the processor receives a fault //! interrupt. This simply enters an infinite loop, preserving the system state //! for examination by a debugger. // //***************************************************************************** static void FaultISR(void) { // // Enter an infinite loop. // while(1) { } } //***************************************************************************** // //! This is the code that gets called when the processor receives an unexpected //! interrupt. This simply enters an infinite loop, preserving the system state //! for examination by a debugger. // //***************************************************************************** static void IntDefaultHandler(void) { // // Go into an infinite loop. // while(1) { } }