lpcware

Re-invoke USB bootloader on LPC11U68

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by neilt6 on Mon May 26 17:03:10 MST 2014
Hey guys, I've been using the following code to re-invoke the USB bootloader on the LPC11U35 QuickStart Board, but it doesn't work on the LPC11U68. I originally thought *((unsigned int *)(0x10000054)) = 0x0; and __set_MSP(*((unsigned int *)0x00000000)); might be the problem, but removing them makes no difference on the LPC11U35, and still doesn't work on the LPC11U68. Anybody have any ideas? It seems to be resetting instead of running the bootloader.


/* This function resets some microcontroller peripherals to reset
* hardware configuration to ensure that the USB In-System Programming module
* will work properly. It is normally called from reset and assumes some reset
* configuration settings for the MCU.
* Some of the peripheral configurations may be redundant in your specific
* project.
*/
void IAP_ReinvokeISP()
{
    //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;

    //Prepare the command array
    m_Command[0] = 57;

    //Initialize the storage state machine
    *((unsigned int *)(0x10000054)) = 0x0;

    //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(*((unsigned int *)0x00000000));

    //Invoke IAP call...
    IAP_Entry(m_Command, m_Result);

    //Shouldn't return
    while(1);
}

Outcomes