I am trying to relocate my Interrupt vector from 0x8000000 to 0x8010000. I start the code in debugger and after calling SystemInit, I set the address manually in VTOR in Register window. The program runs fine. But if I call a routine to set VTOR register then program crashes. Here is my routine:
Do you call it as early as possible means BEFORE any interrupt/exception might occur ?
You could set a breakpoint there and run the application to see if you even reach the code adjusting VTOR. __disable/enable_irq(); doesn’t really help as this function must be invoked before any interupt is enabled.
Usually VTOR adjustment is done in the Reset_Handler before branching to main().
I am calling my routine to change the value in VTOR inside main, after systemInit(), but before my application runs. If changing it manually, this is the place I change manually in the Reg window as well.
Yes, I can put the breakpoint at the code that changes the VTOR value and I see it being changed correctly in the Register window in the debugger
So you can step thru the adjustment function (with interrupts not yet enabled due to MCU reset) and verify the properly changed VTOR value in the debugger ? When does the app crash ?
Hmm … that’s a most likely a completely different issue you should have told earlier.
Standard question is (in case you start using FreeRTOS):
Did you define configASSERT and enable stack checking for development ?
This usually helps a lot to find out and fix initial issues running a FreeRTOS application.
Which FreeRTOS version and which MCU do you use ?
And do you know the valuable FreeRTOS FAQ - links to all RTOS FAQ pages ?
Well, the address of your vector/exception table __vectors can be verified in the map file (output file of the linker). If the vector table is copied into RAM the address is different of course.