cancel
Showing results for 
Search instead for 
Did you mean: 

Issue when setting Vector table register

Scott Dev
Senior
Posted on April 30, 2018 at 17:56

Hi

  I have a booloader application that loads in new firmware in a different part of the flash. After updated I reset the processor and the newly uploaded application doesnt start. I think I must not be updating the vector table correctly because if I simply use the same vector table as the bootloader it works (the small uploaded test application doesnt use interupts). Here is my code in the bootloader.

#define APPLICATION_ADDRESS  (uint32_t)0x08002030

typedef  void (*pFunction)(void);

int boot_NewApp(void)

{

     pFunction JumpToApplication;

    uint32_t JumpAddress;

    // Get the application stack pointer (First entry in the application vector table)

    JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);

    // Get the application entry point (Second entry in the application vector table)

    JumpToApplication = (pFunction) JumpAddress;

    // Reconfigure vector table offset register to match the application location

   SCB->VTOR = APPLICATION_ADDRESS;

    // Set the application stack pointer

     __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);

    // Start the application

     JumpToApplication();

    while(1);

}

If I comment out the 'SCB->VTOR = APPLICATION_ADDRESS;' line, it works as expected by using the bootloader vector table.

Can anyone please let me know what I am doing wrong?

Regards

Scott

11 REPLIES 11
Posted on May 01, 2018 at 20:00

I only had the data sheet and the reference manual

And what's written on the very first page of the reference manual?

(which I couldnt see any reference on the VTOR register)

Then how did you know you need to use it?

Okay, I know I am pushing this now beyond reason, but you get the point.

JW

Posted on May 01, 2018 at 23:51

I downloaded a bootloader example on the stm web site which describes VTOR register. Also, years ago I designed a lot of systems using the 68000 and it’s VBR which does the same job, so I knew the stm32 must have the same process.

Scott