How to relocate interrupt vector table in STM32L151RD?
Hello!
I have written a simple application that reads a byte on USART (in an interrupt) and then sends the same byte back (simple USART echo). I have no problem running this application on various STM32 devices as long as the firmware is programmed at the beginning of FLASH (0x80000000).
I have also managed to run the app from an offset in FLASH (e.g. 0x80001000) using GDB debugger in TrueStudio (I am setting SP and PC in debugger startup script). I am also writing appropriate offset to SCB->VTOR in SystemInit(). This works on STM32L011, STM32F411, but I can't make it work on STM32L151RD.
These are the steps that I am following:
1. Full chip erase.
2. Adjust FLASH region in linker script (ORIGIN = 0x8001000).
3. Set SCB->VTOR in SystemInit() to the same value as above (0x8001000).
4. Set PC and SP in debugger startup script.
5. Build, program and debug.
6. At the beginning of main() verify that SCB->VTOR has appropriate value (the one written to it in SystemInit).
7. Run.
8. Interrupt does not work.
Any idea why interrupts are not firing on STM32L151RD despite following the same procedure which works on other devices? Code optimisation is disabled.
If interrupt vector table is programmed in FLASH not only at my offset (0x80001000) but also at FLASH beginning (0x8000000), interrupt does work. It looks like STM32L151RD is looking for interrupt vector table at the beginning of FLASH despite the fact that SCB->VTOR points to 0x80001000.
Any help would be appreciated!
Bartosz
