Wake-up timer library to wake from deepsleep/power-down

Dependencies:   LPC1114_WakeInterruptIn

Dependents:   LPC812_Sleep_HelloWorld KL05Z_DCF77_RTC_Clock LPC1114_data_logger mBuinoBlinky ... more

You are viewing an older revision! See the latest version

Homepage

Supported Targets

  • LPC812
  • LPC11u24 (it uses the WDT, so not usable if you already use the WDT)
  • KLxxZ (KL05Z, KL25Z and KL46Z verified, but should work on all)
  • K20D50M (Cannot wake from deepsleep when SDA IC is powered, use for example K20 USB port to avoid this)
  • All mbed STM targets (Hopefully. Probably not all, send me a message when you got one which doesn't compile)

Example code

// Depending on the LED connections either the LED is off the 2 seconds
// the target spends in deepsleep(), and on for the other second. Or it is inverted 
 
#include "mbed.h"
#include "WakeUp.h"
 
DigitalOut myled(LED1);
 
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) {
        //Set LED to zero
        myled = 0;
        
        //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();
  
        //Set LED for 1 second to one
        myled = 1;
        wait(1);
    }
}

All wikipages