cancel
Showing results for 
Search instead for 
Did you mean: 

Problems when modifying interrupt vector table in RAM

arnold_w
Senior
Posted on February 16, 2017 at 11:06

I am working with the STM32F045-microcontroller and I write my source code in Eclipse and I build with GNU ARM C/C++ Cross Compiler and I debug using GDB OpenOCD Debugging with ST-LINK/V2. I have placed the interrupt vector table in RAM and it works fine:

__attribute__ ((section('.isr_vector_ram'),used))

uint32_t __isr_vectors_ram[sizeof(__isr_vectors)/sizeof(__isr_vectors[0])];

void moveISRtableToRAM(void) {

    memcpy(__isr_vectors_ram, __isr_vectors, sizeof(__isr_vectors));

    SCB->VTOR = (uint32_t)__isr_vectors_ram;

}

However, I run into problems when I modify it:

void mySoftwareIntHandler(void) {

}

#define SKIP_Cortex_M_Core_Handlers_OFFSET   17

__isr_vectors_ram[SKIP_

Cortex

_

M

_

Core_

Handlers_OFFSET

+ CAN2_RX1_IRQn] = (uint32_t)mySoftwareIntHandler;

My code crashes when I try the above. Does anybody know what's wrong?

1 REPLY 1
Posted on February 16, 2017 at 11:57

Not aware that the F0 Cortex-M0 parts supported changing VTOR. Are you using an F405?

If the code is faulting look at the addresses being written too. Confirm the compiler and linker create the addresses you expect. Do it will manual inspection and math, or have it printf () the values out for you to see.  Make sure the subroutines address is ODD and that it points where expected, compare with .MAP output. 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..