lpcware

LPC1788 bootloader can't jump to user code correctly

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Ivan Sylvan on Tue Nov 12 01:40:47 MST 2013
Hi all!
I'm trying to use bootloader in LPC1788.
BL writes code into the flash memory correctly but it can't jump to user code. I need to jump to 0x2000 but actually it is about 0x680.
What did i do wrong?
Can anybody advice where to get information of how to construct bootloader in LPC1788? As i can see in AN10866_2.pdf for LPC1768 i need to load new VTOR and move SP, PC to new location. And that's it. But i know some people stop PLL, clear INTs and so on in LPC1788. Why? Where can i read about it?
Thanks in advance.

my code (Keil)

__asm void boot_jump( uint32_t address ){
   LDR SP, [R0];Load new stack pointer address
   LDR PC, [R0, #4];Load new program counter address
}

void execute_user_code(void)
{
uint8_t tmp;

NVIC->ICER[0] = 0xFFFFFFFF;//Disable all interrupts
NVIC->ICER[1] = 0x00000001;

NVIC->ICPR[0] = 0xFFFFFFFF;//Clear all pending interrupts
NVIC->ICPR[1] = 0x00000001;
for(tmp = 0; tmp < 32; tmp++)// Clear all interrupt priority
{
NVIC->IP[tmp] = 0x00;
}

LPC_SC->CCLKSEL = 0x01; // set sysclk (12MHz) as clock source
LPC_SC->PLL0CON = 0; // disable PLL
LPC_SC->PLL0FEED = 0xAA;
LPC_SC->PLL0FEED = 0x55;

SCB->VTOR = (0x2000) & 0x1FFFFF80;
boot_jump(0x2000);
}

Outcomes