Part Number: TM4C123GH6PM
Tool/software: Code Composer Studio
what does this section -- .vtable -- in linker script contains doe this contain a copy of the vector table? if so why is it copied to SRAM as it resides in flash already
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.
Part Number: TM4C123GH6PM
Tool/software: Code Composer Studio
what does this section -- .vtable -- in linker script contains doe this contain a copy of the vector table? if so why is it copied to SRAM as it resides in flash already
Hi,
If you are not using any runtime interrupt handler registration then you shouldn't even need the .vtable in the linker command file. But if you do want to use runtime interrupt handler registration then you need to have the .vtable defined. See below excerpt. You can find details in the Peripheral Driver Library user's guide.
This post may also help.
Hi Charles,
Thanks for your reply,
So as i understand that this is only used with run time interrupt handlers but does i have also to change the VECTOR register to point to the same location in SRAM or its done automatically by the api?
Hi,
You do not need to change the NVIC_VTABLE if that is what you are referring to as the VECTOR register. Please see below code. The NVIC_VTABLE will be updated in the API.
void
IntRegister(uint32_t ui32Interrupt, void (*pfnHandler)(void))
{
uint32_t ui32Idx, ui32Value;
//
// Check the arguments.
//
ASSERT(ui32Interrupt < NUM_INTERRUPTS);
//
// Make sure that the RAM vector table is correctly aligned.
//
ASSERT(((uint32_t)g_pfnRAMVectors & 0x000003ff) == 0);
//
// See if the RAM vector table has been initialized.
//
if(HWREG(NVIC_VTABLE) != (uint32_t)g_pfnRAMVectors)
{
//
// Copy the vector table from the beginning of FLASH to the RAM vector
// table.
//
ui32Value = HWREG(NVIC_VTABLE);
for(ui32Idx = 0; ui32Idx < NUM_INTERRUPTS; ui32Idx++)
{
g_pfnRAMVectors[ui32Idx] = (void (*)(void))HWREG((ui32Idx * 4) +
ui32Value);
}
//
// Point the NVIC at the RAM vector table.
//
HWREG(NVIC_VTABLE) = (uint32_t)g_pfnRAMVectors;
}
//
// Save the interrupt handler.
//
g_pfnRAMVectors[ui32Interrupt] = pfnHandler;
}