Reinvoke (ISP) not working

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Lea on Sat Feb 13 00:24:55 MST 2016
I am using a LPCA 11C24 and flash new firmware over the primary CANopen bootloader.
My user app process a command to start the reinvoke function. But this causes a crash. I read in other posts that it is important to turn PLL off, set timer value to it defaults., so I modiy my ipa_reinvoke methode

<code >
* @brief Prepare an invoke µC to call isp-command reinvoke
void iap_reinvoke_bootloader(void)
static uint32_t cmd[5] = {IAP_REINVOKE_ISP_CMD,0,0,0,0};
static uint32_t result[4];

cmd[0] = IAP_REINVOKE_ISP_CMD;// reinvoke ISP command


// make sure 32-bit timer 1 is turned on before calling ISP

// make sure GPIO clock is turned on before calling ISP

// make sure IO configuration clock is turned on before calling ISP

// AHB clock divider must 1:1

// disabele PLL
LPC_SYSCTL->MAINCLKSEL = 0;// enable IRQ oscillator
LPC_SYSCTL->MAINCLKUEN = 0x01;// update MLCK clock source
LPC_SYSCTL->MAINCLKUEN = 0x00;// toggle update register

while (!(LPC_SYSCTL->MAINCLKUEN & 0x01))// wait until updated

// reset the stack pointer to point to the top of the stack minus 32 byte for IAP
// for LPC11Cxx where top of RAM (8kB) is 0x1000_2000: MSP = (0x1000_20000 - 0x20 = 0x1000_1FE0)

/* Set stack pointer to ROM value (reset default) */
__set_MSP(*((uint32_t *) 0x100001FE0));

// the cortex M0 needs to synchronize the CPU cache

Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 3);
Chip_GPIO_SetPinOutLow(LPC_GPIO, 0, 3);

Chip_GPIO_SetPinDIROutput(LPC_GPIO, 0, 1);
Chip_GPIO_SetPinOutLow(LPC_GPIO, 0, 1);

iap_entry(cmd, result);

Does anyone have a tip for me, what am I doing wrong?