Self wake up LPC1347

cancel
Showing results for 
Search instead for 
Did you mean: 

Self wake up LPC1347

Jump to solution
632 Views
santiagoalmando
Contributor II

hello, I'm working with lpc1347 and trying to make a self timed wake up.
i've worked with lpc1114 and 15 and had no problems.
Another thing is that the SCR register is not described in UM10524, where can I find information about memory map?

I modified the PMU example. it looks like the clock stops because when the WFI is not executed (not deep-sleep), the code works fine

#define GPIO_PININT_PIN     24    /* GPIO pin number mapped to PININT */
#define GPIO_PININT_PORT    1    /* GPIO port number mapped to PININT */
#define GPIO_PININT_INDEX   0    /* PININT index used for GPIO mapping */

void PIN_INT0_IRQHandler(void)
{
    NVIC_ClearPendingIRQ(PIN_INT0_IRQn);
    Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(GPIO_PININT_INDEX));
    Chip_TIMER_ExtMatchControlSet(LPC_TIMER32_0, 0, TIMER_EXTMATCH_SET, 0);
    Board_LED_Toggle(0);
}


int main(void)
{   

    SystemCoreClockUpdate();
    Board_Init();


    Board_LED_Set(0, false);

    Chip_IOCON_PinMuxSet(LPC_IOCON, GPIO_PININT_PORT, GPIO_PININT_PIN, (IOCON_FUNC1 |                                                    IOCON_MODE_INACT)); //TIMER32_0_MAT0

   //PININT

    Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_PINT);
    Chip_SYSCTL_SetPinInterrupt(GPIO_PININT_INDEX, GPIO_PININT_PORT, GPIO_PININT_PIN);

    Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(GPIO_PININT_INDEX));
    Chip_PININT_SetPinModeEdge(LPC_PININT, PININTCH(GPIO_PININT_INDEX));
    Chip_PININT_EnableIntHigh(LPC_PININT, PININTCH(GPIO_PININT_INDEX));

    Chip_SYSCTL_EnableStartPin(GPIO_PININT_INDEX);

    NVIC_ClearPendingIRQ(PIN_INT0_IRQn);
    NVIC_EnableIRQ(PIN_INT0_IRQn);

    //CLK

    Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_WDTOSC_PD);
    Chip_Clock_SetWDTOSC(WDTLFO_OSC_0_60, 64);
    Chip_Clock_SetMainClockSource(SYSCTL_MAINCLKSRC_WDTOSC);
    SystemCoreClockUpdate();

   //TIMER

   Chip_TIMER_Init(LPC_TIMER32_0);
    Chip_TIMER_Reset(LPC_TIMER32_0);
    Chip_TIMER_PrescaleSet(LPC_TIMER32_0, 0);
    Chip_TIMER_MatchDisableInt(LPC_TIMER32_0, 0);
    Chip_TIMER_ResetOnMatchEnable(LPC_TIMER32_0, 0);
    Chip_TIMER_StopOnMatchDisable(LPC_TIMER32_0, 0);

    Chip_TIMER_SetMatch(LPC_TIMER32_0, 0, SystemCoreClock*10);
    Chip_TIMER_ExtMatchControlSet(LPC_TIMER32_0, 0, TIMER_EXTMATCH_SET, 0);

      //SLEEP
     Chip_SYSCTL_SetDeepSleepPD(SYSCTL_DEEPSLP_BOD_PD);
     Chip_SYSCTL_PowerDown(SYSCTL_POWERDOWN_IRCOUT_PD | SYSCTL_POWERDOWN_IRC_PD |                                                       SYSCTL_POWERDOWN_BOD_PD | SYSCTL_POWERDOWN_ADC_PD |                                                       SYSCTL_POWERDOWN_SYSOSC_PD | SYSCTL_POWERDOWN_SYSPLL_PD |                                                       SYSCTL_POWERDOWN_USBPLL_PD | SYSCTL_POWERDOWN_USBPAD_PD);
     Chip_SYSCTL_SetWakeup((uint32_t)~(SYSCTL_POWERDOWN_FLASH_PD |                                                                     SYSCTL_POWERDOWN_WDTOSC_PD));

    Chip_TIMER_Enable(LPC_TIMER32_0);

while (1) {
    Chip_PMU_DeepSleepState(LPC_PMU);
}

thank you very much for your help

Labels (2)
Tags (3)
1 Solution
151 Views
santiagoalmando
Contributor II

easy answer. just let it underflow

I will post the code for other users.

void WDT_IRQHandler(void)
{
    uint32_t wdtStatus = Chip_WWDT_GetStatus(LPC_WWDT);

    Board_LED_Toggle(0);
    /* The chip will reset before this happens, but if the WDT doesn't
           have WWDT_WDMOD_WDRESET enabled, this will hit once */
    if (wdtStatus & WWDT_WDMOD_WDTOF) {
        /* A watchdog feed didn't occur prior to window timeout */
        Chip_WWDT_ClearStatusFlag(LPC_WWDT, WWDT_WDMOD_WDTOF);
    }
if (wdtStatus & WWDT_WDMOD_WDINT) {
        /* A watchdog feed didn't occur prior to warning timeout */
        Chip_WWDT_ClearStatusFlag(LPC_WWDT, WWDT_WDMOD_WDINT);
        Chip_WWDT_Feed(LPC_WWDT);
    }
}


int main(void)
{

    uint32_t wdtFreq;

    SystemCoreClockUpdate();
    Board_Init();

    Board_LED_Set(0, false);

    Chip_WWDT_Init(LPC_WWDT);

    Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_WDTOSC_PD);
    Chip_Clock_SetWDTOSC(WDTLFO_OSC_0_60, 64);

    Chip_WWDT_SelClockSource(LPC_WWDT, WWDT_CLKSRC_WATCHDOG_WDOSC);

    wdtFreq = Chip_Clock_GetWDTOSCRate() / 4;

    Chip_WWDT_SetTimeOut(LPC_WWDT, wdtFreq * 5);
    Chip_WWDT_SetWarning(LPC_WWDT, 512);
    Chip_WWDT_SetWindow(LPC_WWDT, wdtFreq * 6);

    Chip_WWDT_ClearStatusFlag(LPC_WWDT, WWDT_WDMOD_WDTOF | WWDT_WDMOD_WDINT);

    NVIC_ClearPendingIRQ(WDT_IRQn);
    NVIC_EnableIRQ(WDT_IRQn);

    Chip_Clock_SetMainClockSource(SYSCTL_MAINCLKSRC_WDTOSC);

    SystemCoreClockUpdate();

    Chip_SYSCTL_EnablePeriphWakeup(SYSCTL_WAKEUP_WWDTINT);

    Chip_SYSCTL_PowerDown(SYSCTL_POWERDOWN_IRCOUT_PD | SYSCTL_POWERDOWN_IRC_PD | SYSCTL_POWERDOWN_BOD_PD | SYSCTL_POWERDOWN_ADC_PD | SYSCTL_POWERDOWN_SYSOSC_PD | SYSCTL_POWERDOWN_SYSPLL_PD | SYSCTL_POWERDOWN_USBPLL_PD | SYSCTL_POWERDOWN_USBPAD_PD);
    Chip_SYSCTL_SetWakeup(~(SYSCTL_POWERDOWN_FLASH_PD | SYSCTL_POWERDOWN_WDTOSC_PD));
    Chip_SYSCTL_SetDeepSleepPD(SYSCTL_DEEPSLP_BOD_PD);


    while (1) {

        Chip_WWDT_Start(LPC_WWDT);        /* Needs restart */

        Chip_PMU_DeepSleepState(LPC_PMU);
    }

    return 0;
}

View solution in original post

4 Replies
152 Views
santiagoalmando
Contributor II

easy answer. just let it underflow

I will post the code for other users.

void WDT_IRQHandler(void)
{
    uint32_t wdtStatus = Chip_WWDT_GetStatus(LPC_WWDT);

    Board_LED_Toggle(0);
    /* The chip will reset before this happens, but if the WDT doesn't
           have WWDT_WDMOD_WDRESET enabled, this will hit once */
    if (wdtStatus & WWDT_WDMOD_WDTOF) {
        /* A watchdog feed didn't occur prior to window timeout */
        Chip_WWDT_ClearStatusFlag(LPC_WWDT, WWDT_WDMOD_WDTOF);
    }
if (wdtStatus & WWDT_WDMOD_WDINT) {
        /* A watchdog feed didn't occur prior to warning timeout */
        Chip_WWDT_ClearStatusFlag(LPC_WWDT, WWDT_WDMOD_WDINT);
        Chip_WWDT_Feed(LPC_WWDT);
    }
}


int main(void)
{

    uint32_t wdtFreq;

    SystemCoreClockUpdate();
    Board_Init();

    Board_LED_Set(0, false);

    Chip_WWDT_Init(LPC_WWDT);

    Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_WDTOSC_PD);
    Chip_Clock_SetWDTOSC(WDTLFO_OSC_0_60, 64);

    Chip_WWDT_SelClockSource(LPC_WWDT, WWDT_CLKSRC_WATCHDOG_WDOSC);

    wdtFreq = Chip_Clock_GetWDTOSCRate() / 4;

    Chip_WWDT_SetTimeOut(LPC_WWDT, wdtFreq * 5);
    Chip_WWDT_SetWarning(LPC_WWDT, 512);
    Chip_WWDT_SetWindow(LPC_WWDT, wdtFreq * 6);

    Chip_WWDT_ClearStatusFlag(LPC_WWDT, WWDT_WDMOD_WDTOF | WWDT_WDMOD_WDINT);

    NVIC_ClearPendingIRQ(WDT_IRQn);
    NVIC_EnableIRQ(WDT_IRQn);

    Chip_Clock_SetMainClockSource(SYSCTL_MAINCLKSRC_WDTOSC);

    SystemCoreClockUpdate();

    Chip_SYSCTL_EnablePeriphWakeup(SYSCTL_WAKEUP_WWDTINT);

    Chip_SYSCTL_PowerDown(SYSCTL_POWERDOWN_IRCOUT_PD | SYSCTL_POWERDOWN_IRC_PD | SYSCTL_POWERDOWN_BOD_PD | SYSCTL_POWERDOWN_ADC_PD | SYSCTL_POWERDOWN_SYSOSC_PD | SYSCTL_POWERDOWN_SYSPLL_PD | SYSCTL_POWERDOWN_USBPLL_PD | SYSCTL_POWERDOWN_USBPAD_PD);
    Chip_SYSCTL_SetWakeup(~(SYSCTL_POWERDOWN_FLASH_PD | SYSCTL_POWERDOWN_WDTOSC_PD));
    Chip_SYSCTL_SetDeepSleepPD(SYSCTL_DEEPSLP_BOD_PD);


    while (1) {

        Chip_WWDT_Start(LPC_WWDT);        /* Needs restart */

        Chip_PMU_DeepSleepState(LPC_PMU);
    }

    return 0;
}

View solution in original post

151 Views
santiagoalmando
Contributor II

I figured out that the way to self wake up is with watchdog timer.
I found that reset of WWDT can be disabled, and using the wake up watchdog in STARTERP1 register the LPC1347 wakes up.
Now the problem is how can I disable/suspend the WWDT between deep-sleep states. feeding it is one way, but i want to, if it's possible, use it only for wake up

0 Kudos
151 Views
soledad
NXP Employee
NXP Employee

Hi,

Please check the below application note, this application note attempts to introduce the various low power modes of the LPC134x and LPC131x series, the steps required to enter the low power modes, wake-up implementation, and helpful hints to reduce power consumption.
This application note also provides a software example to enter the low power modes, and demonstrates how to measure the power consumption and wake-up times using the LPC1343 LPCXpresso board.

http://cache.nxp.com/documents/application_note/AN10973_-_Using_the_LPC13xx_low_power_modes_and_wake... 


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
151 Views
santiagoalmando
Contributor II

Hi soledad,
Thank you for your reply.
The problem is that 1343 is not like 1347 uc.
I based my code from the 1114 code that it's more like the code used at the application note that you linked.

there is not WAKEUP_IRQHandler for example, the pin interrupts are routed,

I can make a wake up code, but manually waked up, and the code without the WFI works OK (that means that the IRQ are working ok, and timer configurated and enabled). but I can not make a self-wakeup.
I assume that it's a clock problem and the timer never match, but i can't find were my problem is.
I read that the 1347 it's like the 11U24 but i cant find an self-wakeup application note of neither 1347 nor 11U24


" Debug limitations
Important: Due to limitations of the ARM Cortex-M3 integration, the
LPC1315/16/17/45/46/47 cannot wake up in the usual manner from Deep-sleep mode. It
is recommended not to use this mode during debug [...]"


But when I debug the PMU example, it works fine.

Thak you again

0 Kudos