8 years, 4 months ago.

FRDM-KL25Z target: possible interference between WakeUp and wait()

I am sorry to say but your example code above does not work for the FRDM-KL25Z target. The problem is with the wait(1); call. If I simply replace it by a simple delay loop then the code works as expected.

example code modified for the FRDM-KL25Z target

#include "mbed.h"
#include "WakeUp.h"

DigitalOut myled(LED1); //LED_RED

int main() {
    //The low-power oscillator can be quite inaccurate on some targets
    //this function calibrates it against the main clock
    WakeUp::calibrate();

    while(1) {
        //Switch LED off
        myled = 1;             //Inverted for the FRDM-KL25Z board

        //Set wakeup time for 2 seconds
        WakeUp::set_ms(2000);

        //Enter deepsleep, the program won't go beyond this point until it is woken up
        deepsleep();

        //Switch LED on for 1 second
        //wait(1);
        //Oops! Cannot use the wait() function here! I am using a primitive delay loop instead
        for(uint32_t i=0; i<2800000; i++) {
            myled = 0;             //Inverted for the FRDM-KL25Z board
        }
    }
}

Question relating to:

Erik - / WakeUp Featured
Wake-up timer library to wake from deepsleep/power-down KL25z, LPC800-MAX, LPC812, powerdown, Sleep, wake-up

Well thats stupid, it used to work :P. (Also with wait statements). The larger issue was that WakeUp and the Ticker use the same hardware, but the library also takes that into account, the wait really shouldn't affect it. I quickly checked, and the calibrate function indeed uses wait also, so it is not that it could be an issue because WakeUp uses the timer while afterwards mbed initializes the timer, calibrate already forced mbed to initialize the timer.

I guess either an update to WakeUp, or to the mbed lib, broke something. I'll have a look at it, but don't expect to get around to it before the weekend. (Then again, who knows :P). I actually ran into an issue of WakeUp not working properly on the Teensy, but that I hadn't tried before, and was something I was still planning to look into.

posted by Erik - 16 Dec 2015

Deepsleep WakeUp was working on the Teensy, I have been using it. Spose I had better have look as well Erik with some existing code to see if anything has changed. Something I did notice, on occasions I need to set a WakeUp::set_ms(0); after a Deepsleep otherwise calling WakeUp::set_ms(n); would cause the program to stop, but that has been like this for some time and mainly affected the STM's. Maybe this needs to be cleared after waking from deepsleep or before setting WakeUp::set_ms(n) again.

posted by Paul Staron 16 Dec 2015

1 Answer

8 years, 4 months ago.

I just ran that code on a KL25 with latest WakeUp and latest mbed lib, and it is running fine for me. So I can't reproduce it.

Accepted Answer

After clicking to "Update All" it works also for me. Thank you for your effort.

posted by Istvan Cserny 27 Dec 2015