LPC812, WKT, deep power down mode: working only once...

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by capiman on Sat Mar 09 09:41:30 MST 2013

i am currently trying to get the LPC812 to use its
deep power down mode and wake up via WKT.

Here is what i am doing:

I start up the chip. UART is working.
LEDs are working.

When a certain key is pressed, i prepare deep power down mode
(see code 1 below before WFI) and enter deep power down
mode via WFI for around 10 seconds.

After around 10 seconds the chip wakes up
and jumps into WKT interrupt service routine.
(see code 2 below)

After returning from WKT ISR, the code after WFI
is continued, UART is working again, everything ok.
(see code 1 below again after WFI,
i removed code for UART and LEDs to make code more readable)

Now i do the same again: press the key,
go to deep power down mode, but the LPC812 does not stay
in deep power down, but immediately goes into WKT ISR.
After WKT ISR the code after WFI is not executed
(different than before).
I already printed a lot registers and compared them
between first and second run, but it seems i have not yet
found the right one...
Is there any additional register which i must clear?
Something like for the pending IRQ, which i already
cleared for WKT_IRQn.

Hardware is (cutted) LPCxpresso with LPC812.
I upload software via FlashMagic.
I have no JTAG/SWI connected.
I assume JTAG/SWI is not helpful,
because it is not working with deep power down mode.
Is this correct?

Has someone already done a similar thing?

Best regards,


Here are some code snippets:
(removed most UART and LED handling used for debugging)

(1) Code executed after key press:

        // Needed?

        // Init self wakeup timer (WKT)

        /* Enable clock for WKT */
        LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 9);

        /* Reset WKT */
        LPC_SYSCON->PRESETCTRL &= ~(1 << 9);
        LPC_SYSCON->PRESETCTRL |=  (1 << 9);

        /* set LPOSCDPDEN and LPOSCEN to 1 */
        LPC_PMU->DPDCTRL |= (3 << 2);

        /* Enable Interrupt for WKT in NVIC */

        /* Config WKT */
        LPC_WKT->CTRL  = (1 << 2);
        LPC_WKT->COUNT = 10 * 10000;
        LPC_WKT->CTRL  = 1;

        /* Set wakeup config to same as run config */

        /* WKT can wake up */
        LPC_SYSCON->STARTERP1 = (1 << 15);

        /* Go to deep power down mode */
        LPC_PMU->PCON = 0x3;


        DebugInitPort(0, 9600);

        DebugPutString("After WFI\n");

(2) WKT-ISR:

void WKT_IRQHandler(void)
  uint32_t regVal;

  // Needed?
  if ( (LPC_PMU->PCON & (0x1<<11)) != 0x0 )
    /* Check deep power down bits. If deep power down mode is entered,
    clear the PCON bits. */
    regVal = LPC_PMU->PCON;
    regVal |= (0x1<<11);
    LPC_PMU->PCON = regVal;

  // Needed?
  if ( (LPC_PMU->PCON & (0x1<<8)) != 0x0 )
    /* Check sleep flag. If sleep flag is set,
    clear the sleep flag. */
    regVal = LPC_PMU->PCON;
    regVal |= (0x1<<8);
    LPC_PMU->PCON = regVal;

  // Without this, WKT-ISR is entered endless...