This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Configure intvecs at an other position than startup_ccs.cpp

Other Parts Discussed in Thread: EK-TM4C1294XL

Hi,

I recently started a project in CCS 6.0.1.00040 on Linux for my Tiva™ C Series Connected Launchpad EK-TM4C1294XL. I successfully added the enet_uip example as a new project to my workspace and refactored the code a little bit. My problem is now that all interrupt callbacks have to be defined in the startup_ccs.cpp like this:

extern void SysTickIntHandler(void);

#ifdef __cplusplus
#pragma DATA_SECTION(".intvecs")
extern "C" void (* const g_pfnVectors[])(void) =
{
#else

#pragma DATA_SECTION(g_pfnVectors, ".intvecs")
void (* const g_pfnVectors[])(void) =
{
#endif
    (void (*)(void))((uint32_t)&__STACK_TOP),
                                            // The initial stack pointer
    ResetISR,                               // The reset handler
    NmiSR,                                  // The NMI handler
    FaultISR,                               // The hard fault handler
    ...
    IntDefaultHandler,                      // I2C9 Master and Slave
    IntDefaultHandler                       // GPIO Port T
};

I want to be able to define an interrupt callback in the corresponding .c/.cpp file in which the function is defined. Is this possible?

For example I have the file "config.cpp" in which the function 'SysTickIntHandler' is defined:

//*****************************************************************************
//
// The interrupt handler for the SysTick interrupt.
//
//*****************************************************************************
void SysTickIntHandler(void) {
	//
	// Increment the system tick count.
	//
	g_ui32TickCounter++;

	//
	// Indicate that a SysTick interrupt has occurred.
	//
	HWREGBITW(&g_ui32Flags, FLAG_SYSTICK) = 1;
}

On position 15 in the 'g_pfnVectors' array in 'startup_ccs.cpp' there is this line:

    SysTickIntHandler,                      // The SysTick handler

But it would be nicer if I could first set the 'IntDefaultHandler' as default and later in 'config.cpp' I want to be able to overwrite position 15 with the function 'SysTickIntHandler' without declaring it first in 'startup_ccs.cpp' too. Is this possible? This way it would be easier to add new interrupts simply by adding them in the correspondig .c/.cpp file where it is defined.

Thank you!

  • Hello user1597705,

    Yes that is possible. It calls for Interrupt Vector remapping by copying the interrupt vector table from the Flash to SRAM, mapping the new interrupt handler to SRAM and then changing the Vector Table Base Address in the VTABLE register.

    The API's for doing so are in the respective driverlib files. As an example for SysTick module it is called SysTickIntRegister(void (*pfnHandler)(void));

    Regards
    Amit
  • Is it also possible to register more than one callback function or do I have to write a little framework with one callback for the SysTick interrupt and then calling one or more functions. For example: I write different codes which all want to register to the same interrupt.
  • Hello user1597705

    Not at the same time. There is only one entry for every Interrupt. It can be changed time to time but still only one Interrupt API will be registered to an interrupt

    Regards
    Amit