Example of using sleep/deepsleep with the LPC812
After some initial code the device goes into powerdown (deepsleep), or sleep mode. By creating a rising edge on pin D0 (I just use a cable to connect it to Vdd) it will leave sleep, blink blue, and go to sleep again. Aditionally after 10 seconds of sleep it will blink green using the low-power wake-up timer.
Brownout detection and Watchdog timer are disabled since in deepsleep they are the primary power consumers.
Diff: main.cpp
- Revision:
- 0:273b2570ead8
- Child:
- 1:85ca0ec1e66f
diff -r 000000000000 -r 273b2570ead8 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Nov 20 21:26:47 2013 +0000 @@ -0,0 +1,27 @@ +#include "mbed.h" + +DigitalOut myled(LED1); +InterruptIn inter(D0); + + +void interirq(void) { + +} + +int main() { + inter.rise(interirq); + + //Disable BOD and WDT: + LPC_SYSCON->PDRUNCFG |= (1<<3) | (1<<6); + + while(1) { + for (int i = 0; i<10; i++) { + myled = 0; + wait(0.2); + myled = 1; + wait(0.2); + } + //sleep(); + deepsleep(); + } +}