Rev | Line | |
---|
[224] | 1 | /***********************************************************************************************
|
---|
| 2 | This sketch demonstrates how to use sleep features and wake-up MCU with RTC alarm interrupt.
|
---|
| 3 | This sketch works only on cortex-m0+ based boards.
|
---|
| 4 | ************************************************************************************************/
|
---|
| 5 |
|
---|
| 6 | #include <EnergySaving.h>
|
---|
| 7 | #include <RTCInt.h>
|
---|
| 8 |
|
---|
| 9 | EnergySaving nrgSave;
|
---|
| 10 | RTCInt rtc;
|
---|
| 11 |
|
---|
| 12 | unsigned int i=0;
|
---|
| 13 |
|
---|
| 14 | void setup()
|
---|
| 15 | {
|
---|
| 16 |
|
---|
| 17 | pinMode(30,OUTPUT); //led RX
|
---|
| 18 | Serial5.begin(9600); //serial settings
|
---|
| 19 | rtc.begin(TIME_H24);
|
---|
| 20 | rtc.setTime(12,48,0,0);
|
---|
| 21 | rtc.setDate(22,10,15);
|
---|
| 22 | rtc.enableAlarm(SEC,ALARM_INTERRUPT,rest_alarm_int);
|
---|
| 23 | rtc.local_time.hour=12;
|
---|
| 24 | rtc.local_time.minute=48;
|
---|
| 25 | rtc.local_time.second=30;
|
---|
| 26 | nrgSave.begin(WAKE_RTC_ALARM); //standby setup for external interrupts
|
---|
| 27 | rtc.setAlarm();
|
---|
| 28 | SerialUSB.println("START");
|
---|
| 29 |
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | void loop()
|
---|
| 33 | {
|
---|
| 34 | for(i=0; i<20; i++)
|
---|
| 35 | {
|
---|
| 36 | digitalWrite(13,HIGH);
|
---|
| 37 | delay(500);
|
---|
| 38 | digitalWrite(13,LOW);
|
---|
| 39 | delay(500);
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | digitalWrite(30,LOW);
|
---|
| 43 | nrgSave.standby(); //now mcu go to standby
|
---|
| 44 |
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | void rest_alarm_int(void) //interrupt routine
|
---|
| 48 | {
|
---|
| 49 | //PORT->Group[1].OUTSET.reg = 0x1u<<3;
|
---|
| 50 | digitalWrite(30,HIGH);
|
---|
| 51 |
|
---|
| 52 | Serial5.println("HELLO");
|
---|
| 53 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.