lpcware

LPC11U24 and IAP Reinvoke ISP

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by tarmo on Fri May 18 04:02:52 MST 2012
Hi

How do i start ISP as [B]MSC USB device[/B] on LPC11U24 using [B]IAP Reinvoke ISP[/B] command (57).  The following code works well on LPC1343 but not on LPC11U24.
I can execute ISP as USB MSC device during reset or power on (PIO0_1 low & PIO0_3 high).
All other IAP commands are working well. So i think the problem is with init_msdstate() function.


#define IAP_LOCATION 0x1fff1ff1
typedef void (*IAP)(unsigned int[], unsigned int[]);
IAP iap_entry = (IAP) IAP_LOCATION;
#define CMD_SUCCESS 0

unsigned int Command[5];
unsigned int Result[4];

#define init_msdstate() *((uint32_t *)(0x10000054)) = 0x0

void EnterISP(void) {
/* make sure USB clock is turned on before calling ISP */
LPC_SYSCON->SYSAHBCLKCTRL |= 0x04000;
/* make sure 32-bit Timer 1 is turned on before calling ISP */
LPC_SYSCON->SYSAHBCLKCTRL |= 0x00400;
/* make sure GPIO clock is turned on before calling ISP */
LPC_SYSCON->SYSAHBCLKCTRL |= 0x00040;
/* make sure IO configuration clock is turned on before calling ISP */
LPC_SYSCON->SYSAHBCLKCTRL |= 0x10000;
/* make sure AHB clock divider is 1:1 */
LPC_SYSCON->SYSAHBCLKDIV = 1;

/* Send Reinvoke ISP command to ISP entry point*/
Command[0] = 57;

init_msdstate(); /* Initialize Storage state machine */
/* Set stack pointer to ROM value (reset default) This must be the last
piece of code executed before calling ISP, because most C expressions
and function returns will fail after the stack pointer is changed. */
__set_MSP(*((uint32_t *) 0x1FFF0000)); /* inline asm function */

/* Enter ISP. We call "iap_entry" to enter ISP because the ISP entry is done
through the same command interface as IAP. */
iap_entry(Command, Result);
// Not supposed to come back!
}

Outcomes