Enter power-down mode, but couldn't wake it up using an interrupt from a real time clock (RTC) interrupt

Dependencies:   PowerControl RTC mbed

Files at this revision

API Documentation at this revision

Comitter:
weidongguo
Date:
Mon Feb 22 06:57:25 2016 +0000
Parent:
0:35c76e921818
Commit message:
1)Power down most peripherals except for GPIO for LEDs and UART0 for serial port communication. 2) Can enter sleep mode and be waken by a RTC interrupt every minute after the first 5 seconds

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 35c76e921818 -r 635eaebcd13f main.cpp
--- a/main.cpp	Thu Feb 18 08:13:37 2016 +0000
+++ b/main.cpp	Mon Feb 22 06:57:25 2016 +0000
@@ -1,31 +1,37 @@
 #include "mbed.h"
 #include "PowerControl.h"
+#include "EthernetPowerControl.h"
 #include "RTC.h"
-
 DigitalOut leds[] = {DigitalOut(LED1), DigitalOut(LED2), DigitalOut(LED3), DigitalOut(LED4)}; // put each LED object into an array, easier to access
+Serial pc(USBTX, USBRX);
 
 void ISR(void){
-    DigitalOut led = DigitalOut(LED4);
-    led = 1;
-    
     leds[2] = !leds[2];
-    if(! (LPC_SC->PCON & 0x400) )
-        leds[1] = !leds[1];
+    leds[1] = !leds[1];
  }
  
  
 int main() {
-    set_time(1455622440); // Tue, 16 Feb 2016 11:34:00 GMT
-    //set up real-time clock(RTC) interrupt
+    
+    //turn off other unused peripherals
+    Peripheral_PowerDown( ~(LPC1768_PCONP_PCUART0 | LPC1768_PCONP_PCGPIO) );
+   //turn off everything except for GPIO for LED and UART0 for serial port communication.
+
+    set_time(1456096500); // Sun, 21 Feb 2016 23:15:00 GMT
     tm t = RTC::getDefaultTM();
-    t.tm_sec = 3; //when the second is 3 for the real time, once every minute
- 
-    RTC::alarm(&ISR, t);
-
+    t.tm_sec = 5;
+    RTC::alarm(&ISR, t); //send interrupt to wake up from sleep() mode .
+                        // the RTC sends one interrupt every minute after the first 5 seconds
+    leds[0] = 1;  
+    char ch;
     while (true) {
-       leds[0] = !leds[0];
-       wait_ms(1000);
-       PowerDown();
+       if(pc.readable()){
+        ch = pc.getc();
+        pc.putc(ch); 
+       }
+       
+       leds[3] = !leds[3];
+       sleep(); 
     }
 }
 
diff -r 35c76e921818 -r 635eaebcd13f mbed-rtos.lib
--- a/mbed-rtos.lib	Thu Feb 18 08:13:37 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#f62a48e9da94
diff -r 35c76e921818 -r 635eaebcd13f mbed.bld
--- a/mbed.bld	Thu Feb 18 08:13:37 2016 +0000
+++ b/mbed.bld	Mon Feb 22 06:57:25 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/f141b2784e32
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3
\ No newline at end of file