AnsweredAssumed Answered

Jump to bootloader from main application

Question asked by Dawid Stysiak on Jul 28, 2016
Latest reply on May 3, 2017 by Kerry Zhou


I use LPC1114. I have bootolader at 0x0000 address. I jump from this boolader to main application at 0x1000. This works perfect. Now I have to invoke bootloader from main application. I know that I can use NVIC_SystemReset(), but this software reset changes GPIO pin state. In my case GPIO states should be the same. So I have to invoke bootloader different way. The only possible way is jump to 0x0000 address. My idea:

__disable_irq();

 

SPI_Disable_Interrupts();

Chip_TIMER_DeInit(LPC_TIMER16_0);

Chip_ADC_DeInit();
SysTick_disable();

 

LPC_SYSCTL->SYSMEMREMAP = 0x2;  // remap to internal flash

   

LPC_SYSCON->MAINCLKSEL  = 0;   //Internal oscillator

LPC_SYSCON->MAINCLKUEN  = 0;

LPC_SYSCON->MAINCLKUEN  = 1;

 

for (i=0; i<50000; i++);   //some delay

 

stackPointer = *(uint32_t*)(0);

  __set_MSP(stackPointer);

 

user_entry = (USER_ENTRY_PFN)*((uint32_t*)(4));

(user_entry)();

 

is this correct? I use in bootloader SPI. How can I reset SPI interface to default value?

Outcomes