AnsweredAssumed Answered

Reinvoke ISP (LPC1224)

Question asked by Alberto Savazzi on Mar 6, 2017
Latest reply on Mar 12, 2017 by jeremyzhou

I'm trying to program LPC1224 using the reinvokeisp mode from user code but I'still have no answer to a sync character '?'.

 

void ReinvokeISP(void)
{

/* disable WatchDog */
LPC_WWDT->MOD = 0;

__disable_irq();

/* make sure 32-bit Timer 1 is turned on before calling ISP */
LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 10) | (1 << 10);
/* make sure GPIO clock is turned on before calling ISP */
LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 29) | (1 << 30) | (1 << 31); //0x00040;
/* make sure IO configuration clock is turned on before calling ISP */
LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 16); //0x10000;

// AHB clock divider must 1:1
LPC_SYSCON->SYSAHBCLKDIV = 1;

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

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

// the cortex M0 needs to synchronize the CPU cache
__ISB();

LPC_GPIO0->DIR |= (1<<12); //set GPIO0_12 DIR out
LPC_GPIO0->CLR = (1<<12);

command[0] = IAP_CMD_REINVOKE;

// 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 *) 0x1FFF0000));

iap_entry(command, output);

}

 

Please help, I spent many days with no success.

 

Thanks.

Outcomes