Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 11 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 } } }
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 2015Deepsleep 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