9 years, 10 months ago.

deepsleep() isn't working as expected

Using the following code in FRDM-KL25Z:

include the mbed library with this snippet

#include "mbed.h"
#include "rtos.h"

DigitalOut ledr(LED_RED);
Ticker t;

void isro(void)
{
    ledr = !ledr;
}

int main()
{
    ledr = 0;
    t.attach(&isro, 3.0);
    deepsleep();
}

It works as expected soon as I restart the board using the board button (it keeps turning on and off the LED at 3 seconds intervals). If I remove USB and plug it again, it keeps the LED on and doesn't work anymore. Does anyone knows why it stops to work if I unplug and plug the power of the board ?

PS: If I change deepsleep() to sleep() it works fine.

Question relating to:

The FRDM-KL25Z is an ultra-low-cost development platform for Kinetis L Series KL1x (KL14/15) and KL2x (KL24/25) MCUs built on ARM® Cortex™-M0+ processor. Features include easy access to MCU I/O, battery-ready, …

2 Answers

9 years, 10 months ago.

Try Erik's WakeUp library instead of using the Ticker.

https://developer.mbed.org/users/Sissors/code/WakeUp/

Accepted Answer
9 years, 10 months ago.

Hi,

one thing to be said, Ticker does not have any requirement to wake up from deep_sleep(). it's true for most of platforms. Look at Paul above suggested , at WakeUp timer, which on the other hand , is using low power timers.

A nice comment about this in the Ticker documentation would be nice. Do you know if the community has access to modify the Wiki documentation ?

posted by Christian Perone 17 Jan 2015

which wiki are you reffering to? We will add more information about ticker and deep sleep , this should be there

posted by Martin Kojtal 17 Jan 2015