AnsweredAssumed Answered

Deep-Sleep Issue

Question asked by Ranjith Shanbhag on May 20, 2017
Latest reply on May 26, 2017 by jeremyzhou

Hi,

 

I am working on LPC824, after wake-up from Deep-sleep mode a system reset is required. Can anybody tell me how to get normal function without system reset?
Below is my code:

 

void Setup_Low_Power_Mode(void)
{

    // Power down the BOD and ACMP_PD since we are not using it
    LPC_SYSCON->PDSLEEPCFG |= (BOD_PD | ACMP_PD | ADC_PD | WDTOSC_PD | SYSOSC_PD);

 

    // Turn clocks off to unused peripherals (Leave UART0, UART2 on!)
    LPC_SYSCON->SYSAHBCLKCTRL &= ~(UART0 | UART1 | UART2 | ADC | ACMP | SCT | IOCON | MRT | DMA | SWM
            | MTB | I2C0 | I2C3 | I2C2 | I2C1 | WWDT | CRC | SPI1 | SPI0);

 

        /* 10KHz clock source */
        LPC_WKT->CTRL |= 1;    /* using Low Power clock 10kHz */

 

        /* Setup for wakeup in timeout */
        LPC_WKT->COUNT = (10000 * 2);        /* 10KHz * 2S */

 

    /* We should call Chip_SYSCTL_SetWakeup() to setup any peripherals we want
       to power back up on wakeup. For this example, we'll power back up the IRC,
       FLASH, the system oscillator, and the PLL */
    LPC_SYSCON->PDAWAKECFG &= ~(BOD_PD | SYSPLL_PD | IRCOUT_PD | IRC_PD | FLASH_PD | ADC_PD | SYSOSC_PD  | WDTOSC_PD | ACMP_PD);

 

    LPC_SYSCON->STARTERP1 = 1<<15;        /* WKT interrupt */
    LPC_SYSCON->MAINCLKSEL = 0<<0;

 

    // PCON = 1 selects Deep-sleep mode
    LPC_PMU->PCON = 0x1;
    // Set the SleepDeep bit
    SCB->SCR |= (1<<2);

 

    // Wait here for wake up command.
    __WFI();

}

 

 

 

 

void Config_WKT(void)
{
    /* Alarm/wake timer as chip wakeup source */
    LPC_SYSCON->STARTERP1 = (1 << 15) | (LPC_SYSCON->STARTERP0 & (0xff));

 

    /* Enable and reset WKT clock */
    LPC_SYSCON->SYSAHBCLKCTRL = (1 << 9) | (LPC_SYSCON->SYSAHBCLKCTRL & ~(0xda100000));

 

    LPC_SYSCON->PRESETCTRL &= ~((1 << (uint32_t) 9) |  0xfffe2000);
    LPC_SYSCON->PRESETCTRL = (1 << (uint32_t) 9) | (LPC_SYSCON->PRESETCTRL & ~0xfffe2000);

 

    /* Disable wakeup pad */
    /** Disable the Wake-up */
    /** Enable the low-power oscillator in deep power-down*/
    LPC_PMU->DPDCTRL &= ~((1 << 1) | (1 << 3) | (~0xf));

 

    /* Disable wakeup hysteresis by setting the bit (set to disable),
       enable 10KHz oscillator for all power down modes including deep
       power-down */
    /** Enable wake-up pin hysteresis */
    /** Enable the low-power oscillator (10 khz self wk) */
    /** Enable the low-power oscillator in deep power-down*/
    LPC_PMU->DPDCTRL = ((1 << 0) | (1 << 2) | (1 << 3) | (LPC_PMU->DPDCTRL & ~(~0xf)));


    /* Enable WKT interrupt */
    NVIC_EnableIRQ(WKT_IRQn);
}

 

 

void WKT_IRQHandler(void)
{
    /* Clear WKT interrupt request */
    LPC_WKT->CTRL = ((uint32_t) (1 << 1))    /*!< Wake-up or alarm timer flag */
                    | (LPC_WKT->CTRL & (7));

 

    /*!< Clears the self wake-up timer */
    LPC_WKT->CTRL = ((uint32_t) (1 << 2))    /*!< Clear and stop WKT counter */
                    | (LPC_WKT->CTRL & (7));

    LPC_SYSCON->SYSAHBCLKCTRL |= (UART2 | GPIO | ADC | ACMP | SCT | IOCON | MRT | DMA);

 

NVIC_SystemReset();
      return;
}

Outcomes