This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with sleep and deepsleep in the same application (using RTX)

Hello guys,
this is (maybe) not exactly Keil specific but I'm trying here anyway ;)
I have an application using Keil RTX running on a LPC1778.

My os_idle_demon() in RTX_Conf_CM.c looks like this:

__task void os_idle_demon (void) {
  /* The idle demon is a system task, running when no other task is ready */
  /* to run. The 'os_xxx' function calls are not allowed from this task.  */
  int x;
  for (;;) {
    // Only enable sleep if not running in debugger
    if ((CoreDebug->DHCSR & 0x0001)==0) {
      LPC_SC->PCON = 0x00;
      SCB->SCR = 0x00;
      __WFI();
    }
  }
}

Basically this will put the CPU in Sleep when no task is ready to run. Works perfect.

I then added a call to CLKPWR_PowerDown() in a function (when a button is pressed). The CLKPWR_PowerDown() funtion looks like this:

/*********************************************************************//**
 * @brief               Enter Power Down mode with co-operated instruction by the Cortex-M3.
 * @param[in]   None
 * @return              None
 **********************************************************************/
void CLKPWR_PowerDown(void)
{
    /* Deep-Sleep Mode, set SLEEPDEEP bit */
        SCB->SCR = 0x4;
        LPC_SC->PCON = 0x09;
        /* Power Down Mode*/
        __WFI();
}

This function also works as supposed.

BUT!

If I activate the deepsleep mode, the CPU will correctly go to deepsleep and wake up when an enabled interrupt fires (another GPIO pin). Only one problem, when waking up the CPU resets itself!
This ONLY occurs if I have the Sleep code enabled in the os_idle_demon() !
I I disable the sleep code in the os_idle_demon() and enable it maybe 10 seconds later (using another button) it will reset immediatly!

So, Sleep on it's own works, deepsleep on it's own work, but when doing deepsleep followed by sleep the CPU resets.
The other way around it is ok, the system can run forever just using the sleep in the os_idle_demon() and it also works when activating deepsleep. It is only when exiting from deepsleep and then doing sleep at some point in time in os_idle_demon() that the system resets.....

Any ideas out there before I loose the rest of my hair ?

Parents Reply Children
  • You might have to send a mail to a NXP support engineer to ask about limitations of the sleep functions - and please update this thread with the outcome of such a query.

    Note that the processor has an internal DC-DC since the core isn't running at 3V3. So maybe there are issues/limitations with the internal startup sequence of the processor after the deep sleep. I think at least some of the NXP chips can only reset after a deep sleep because they have powered off so much internal functionality that the processor can't restore all required state to allow the processor to just wake up and continue.

    But any limitations should be documented in the latest processor user manual, or the latest errata.

  • Per,
    I have made a request to NXP also, I will write the outcome here also.

    As I wrote I can delay the sleep 10 minutes after the device has been woken up from the deepsleep and it still happens, as soon as the sleep is invoked the CPU resets with the BOD reset and SYSRESETREQ flags set in RSID), the device starts immediatly from deepsleep when the interrupt occurs and the first thing I do is to initialize the PLLs and the clock divisors (as per the users manual).