Never wakes up from Deep Sleep

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 18, 2016 by lpcware
Content originally posted in LPCWare by KaareBK on Fri Mar 18 08:10:06 MST 2016

I have a simple application where I want to:

- Take an analogue sample.
- Go to deep Sleep for 10 ms.
- Tale a new sample
- Sleep
- etc...

The plan is to make the WD run during sleep, and let it generate an interrupt when timer expires, which should wake up the cpu.

What I can do right now, is entering Deep Sleep.
And I can make the WD reset the cpu when timer expires. This means that the WD timer is running OK during Sleep.
But when i want to make just a IRQ when timer expires, it never wakes up.

System details:
- LPC1225
- Running on IRC
- Rowley Crossworks IDE

Here is how I do:


// Enter Deep Sleep:
    LPC_SYSCON->SYSAHBCLKCTRL |= (1<<15); // Enable WD clock
    LPC_WWDT->TC     = 0x1000;              // Set timer (appr. 1 sec at the moment)
    LPC_WWDT->CLKSEL = 1;                   // select watchdog oscillator as Watchdog clock source
    LPC_WWDT->MOD    = 1;                   // WD timeout = IRQ
//    LPC_WWDT->MOD    = 3;                 // WD timeout = IRQ + CPU Reset
    LPC_WWDT->FEED   = 0xAA;                // Load WD registers
    LPC_WWDT->FEED   = 0x55;                // load WD registers

    // Enable WD IRQ:

    LPC_SYSCON->PDSLEEPCFG &= ~(1<<6); // WD timer running during deep sleep
    SCB->SCR |= (1 << 2); // Select deep sleep mode

    __WFI(); // Enter Sleep mode

I have this handler for the interrupt:

void WDT_IRQHandler( void )
  // Clear sleep bit:
  SCB->SCR &= ~(1 << 2);

  LPC_SYSCON->MAINCLKSEL    = 0;     /* Select PLL Clock Output  */
  LPC_SYSCON->MAINCLKUEN    = 0x01;               /* Update MCLK Clock Source */
  LPC_SYSCON->MAINCLKUEN    = 0x00;               /* Toggle Update Register   */
  while (!(LPC_SYSCON->MAINCLKUEN & 0x01));       /* Wait Until Updated       */

  // Turn ON an LED to indicate wakeup:
  GPIOSetPortBit( Status_LED_GREEN_PORT, Status_LED_GREEN_PIN, ON );

I have read several forum posts, user manuals and application notes, and have tried pretty much everything...
But it still don't wake up from sleep.

I am convinced that I am close to the target, as I can make the WD run suring sleep, and is able to make the cpu reset at WD timeout.
But I can't make the WD IRQ wake up the cpu.

Thanks in advance for any help !