Problems with VTOR on LPC11U68

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problems with VTOR on LPC11U68

1,137 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by valenti on Fri Jan 09 04:51:45 MST 2015
I have a firmware with two modules (projects):
1- own Bootlader module
2- main Application module
The Bootloader checks for valid Application and if correct changes Vector Table with VTOR register and jumps to this module.
This mecanism work fine with a similar firmware for LPC1758 (based on CMSIS 2.0) but with an LPC11U68 (based on LPCOpen v2.06) seems to hang. To achieve this I have modified the cmsis.h with a patch found in another topic for LPC8xx (another Cortex-M0+):
- replacing
    #define __CM0_REV                 0x0000/*!< Cortex-M0 Core Revision                          */
  with
    #define __CM0PLUS_REV             0x0001/*!< Cortex-M0+ Core Revision                         */
- adding
    #define __VTOR_PRESENT            1/*!< VTOR is present in this implementation           */

Is this changes on LPCOpen enough to use VTOR register?
Does anyone know if LPC11U68 really accepts the VTOR register? (According their User Manual seems it should)

This is the code used for BootLoader to jump to the Application:

void execute_code(unsigned addr)
{   void (*user_code_entry)(void);
    unsigned *p;    // used for loading address of reset handler from user flash

    // Change the Vector Table to the addr (if user application uses interrupts)
    SCB->VTOR = (addr & 0x1FFFFF80);

    // Load contents of second word of user flash - the reset handler address
    // in the applications vector table
    p = (unsigned *)(addr +4);

    // Set user_code_entry to be the address contained in that second word of user flash
    user_code_entry = (void *) *p;

    // Jump to user application
    user_code_entry();
}

Please help me!!!
Thanks in advance.
Labels (1)
6 Replies

677 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by valenti on Mon Jan 12 09:25:38 MST 2015
I followed all your advice, but I forgot to re-enable interrupts in the Application module module. Now everything works perfectly. R2D2 thank you very much for your help.
0 Kudos

677 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Fri Jan 09 09:33:38 MST 2015
I'm not sure what you are doing in detail, but beside switching the MCU to default status (IRC, disabled interrupts) before jumping to your application it's of course important that your flash is containing a correct application (especially with correct vector table)  :)

So I would recommend to use the debugger to check application vector table and then debug your code...
0 Kudos

677 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by valenti on Fri Jan 09 08:56:54 MST 2015
- I have added  assign the new stack pointer anyway, but with the same result.
    __set_MSP(*(__IO uint32_t*)addr); // Set top stack handler before jump

- I already tried working with IRC before.

In this moment I have inoperative the debug board and I test it updating firmware with flashmagic, but I know that is not working because the Application must blink a LED and it does not. When I try with only Application module, without BootLoader module, it works properly.
0 Kudos

677 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Fri Jan 09 07:32:21 MST 2015

Quote: valenti
1. You don't assign the new stack pointer  -> That's true. I don't know if is strictly necessary but with LPC1758 I never have been problems.



You'll find LPC17 threads about this...


Quote: valenti
2. Which clock are you using? IRC  -> I use the Chip_SetupXtalClocking(void) function of LPCOpen to configure external oscillator (with XTAL of 12MHz).



It's useful to switch to IRC before jumping ...

BTW: What's the debugger telling you about the problem?
0 Kudos

677 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by valenti on Fri Jan 09 07:15:43 MST 2015


1. You don't assign the new stack pointer  -> That's true. I don't know if is strictly necessary but with LPC1758 I never have been problems.

2. Which clock are you using? IRC  -> I use the Chip_SetupXtalClocking(void) function of LPCOpen to configure external oscillator (with XTAL of 12MHz).
0 Kudos

677 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Fri Jan 09 05:12:21 MST 2015

Quote: valenti
Please help me!!!



1. You don't assign the new stack pointer  :((

2. Which clock are you using? IRC  :quest:
0 Kudos