8

I'm using a STM32F107 cortex m3 microcontroller. I'm using the Keil uvision IDE for the project. I have an application which is running properly at the starting location i.e 0x0800 0000. If I change the starting location to 0x0800 4000 the application is not working properly. I made changes to the vector table location using this function as such:

NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x8004000)

i.e changed SCB->VTOR = 0x8004000 to this location.

But even after doing this interrupt is not happening. Should I do anything more to make this project work?

artless noise
  • 21,212
  • 6
  • 68
  • 105
suraj
  • 283
  • 3
  • 5
  • 13
  • I suspect you are trying to say that the vector table in your application is re-located to 0x0800.0000 after boot up, and now you're trying to move it to 0x0800.4000? Have you verified that the vector table is actually located by your toolset at the new address? And you say "the interrupt is not happening" - what exactly does that mean? A lot has to go right in between a peripheral asserting an interrupt and you running your ISR - stack setup, enable interrupts at CPU, NVIC interrupt priority, proper interrupt vector installed, peripheral interrupt unmasked, etc. – Dan Feb 07 '13 at 12:46
  • When I looked at the map file ,the vector table is located at 0x0800 4000 itself. I think there is some initialization error. checking on that – suraj Feb 11 '13 at 06:08
  • 1
    This is not the answer to your question, but I'd suggest that you make a global or static array, which is large enough to contain a duplicate of the vector table and pointing the vector to this, instead of setting the address directly. The reason for my suggestion is that as your program grows, it might allocate variables that overwrite the vector table, as variables get allocated. Another solution is to edit the linker-script and reserve enough space for a vector table there. –  May 04 '13 at 00:49

3 Answers3

9

You should not use NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x8004000), use NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x4000). The second argument is the "offset", not the absolute address.

Grissiom
  • 11,355
  • 3
  • 18
  • 23
  • 1
    One should take care of vector table alignment. ARM says: "The vector table base must always be aligned to at least the number of exception vectors implemented". See VTOR register description for details. – iFred Apr 25 '19 at 18:48
1

Add the below instruction just after the HAL_Init();

SCB->VTOR = (FLASH_BASE | 0x4000);

You also need to update the interrupt vector address in the STM32F1xc_flash.icf file as below.

define symbol ICFEDIT_intvec_start = 0x08004000;

-1

I did this for my STM32L496, and it was important to set the new vector table before calling HAL_Init(), because it calls HAL_MspInit(), which may use the SysTick to measure timeouts while setting up some peripherals.