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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

726 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by capiman on Sat Mar 09 09:41:30 MST 2013
Hello,

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,

Martin


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

(1) Code executed after key press:

        // Needed?
        NVIC_ClearPendingIRQ(WKT_IRQn);
        NVIC_DisableIRQ(WKT_IRQn);

        // 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 */
        NVIC_EnableIRQ(WKT_IRQn);

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

        /* Set wakeup config to same as run config */
        LPC_SYSCON->PDAWAKECFG = LPC_SYSCON->PDRUNCFG;

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

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

        SystemCoreClockUpdate();

        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...
  NVIC_DisableIRQ(WKT_IRQn);
}
Labels (1)
0 Kudos
3 Replies

467 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by capiman on Sat Mar 09 10:42:15 MST 2013
Mike,

this was it!!!

I added clearing the ALARMFLAG located WKT->CTRL inside the WKT ISR and now going to deep power down mode works multiple times.

Many many thanks!

Best regards,

Martin
0 Kudos

467 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheShed on Sat Mar 09 10:13:37 MST 2013
Martin,

Did you clear the ALARMFLAG in WKT->CTRL ? I couldn't see it in your code...


--
mike
0 Kudos

467 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by capiman on Sat Mar 09 09:42:39 MST 2013
Inside WKT ISR

SCB->ICSR=0000001F

which seems to be correct because i am in ISR for WKT (31-16=15)

After ISR of WKT one bit

SCB->ICSR=00400000

remains set, even after

NVIC_ClearPendingIRQ(WKT_IRQn);
NVIC_DisableIRQ(WKT_IRQn);

Bit 2^22 means ISRPENDING

according to

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0497a/Cihfaaha.html

Is there any way to clear ISRPENDING?
0 Kudos