Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freeze after Standby #33

Closed
jamesfahlbusch opened this issue Dec 5, 2017 · 3 comments
Closed

Freeze after Standby #33

jamesfahlbusch opened this issue Dec 5, 2017 · 3 comments

Comments

@jamesfahlbusch
Copy link

After waking from the RTCZero Standby the system freezes when I attempt to use interrupts. Is something not being reset after standby?
I am using a library called Retick that throttles the loop and utilizes TCC1 and it is getting stuck at the first instance of _WFI() after standby. Are the interrupts not being cleared?

#include <RTCZero.h>
#include "Arduino.h"
#include "retick.h"

#define RED 13 // Red LED on Pin #13
#define GREEN 8 // Green LED on Pin #8
#define VBATPIN A7 // Battery Voltage on Pin A7

// re-defines USB serial from M0 chip so it appears as regular serial
#if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL)
// Required for Serial on Zero based boards
#define Serial SERIAL_PORT_USBVIRTUAL
#endif

/////////////// Key Settings ///////////////////

byte hours = 0;
byte minutes = 0;
byte seconds = 0;
byte day = 1;
byte month = 1;
byte year = 17;
byte Start = 0;
byte retickRate = 2000;

/////////////// Global Objects ////////////////////
RTCZero rtc; // Create RTC object

////////////// Setup ///////////////////
void setup() {
rtc.begin(); // initialize RTC
Serial.begin(9600);
while (!Serial);
Serial.println("Setup");
rtc.begin(); // initialize RTC
rtc.setTime(hours, minutes, seconds);
rtc.setDate(day, month, year);
rtc.setAlarmTime(hours, minutes, seconds + 20);
rtc.setAlarmDate(day, month, year);
rtc.enableAlarm(rtc.MATCH_YYMMDDHHMMSS);

Serial.println("Entering Standby");

rtc.standbyMode();

rtc.disableAlarm();
rtc.detachInterrupt();
rtc.updateAlarms();
delay(5000);

}

///////////////////// Loop //////////////////////
void loop() {
//Serial.begin(9600);
Serial.println("Entering Loop");
/* Each run-through of tick will be 20ms (50Hz)

  • If it takes less than 20ms, the CPU will sleep
  • If it takes more, it immediately goes into next
  • tick once the previous finishes
    */
    retick(retickRate);
    }

///////////////////// ReTick //////////////////////
void tick() {

Serial.println("Entering retick loop");
while(1) {
uint8_t i;
for (i=0; i<2; i++) {
  digitalWrite(13, HIGH);
  delay(500);
  digitalWrite(13, LOW);
  delay(500);
}
for (i=2; i<10; i++) {
  delay(300);
}

}

}

@wjpavalko
Copy link

I'm having a very similar issue. I built a bunch of ocean buoys with the SAMD21 chip on a Adafruit Feather M0. Each buoy will work fine for hrs then eventually hang after going into standby sleep mode. Oddly, some buoys with different hardware configurations (additional sensors) experience this much less often (need to run for weeks).

Any ideas?

` //Put Feather M0 in Standby for 30 sec

Alarm_Time += 30;
Alarm_Time = Alarm_Time % 60;
rtc1.setAlarmSeconds(Alarm_Time);
rtc1.enableAlarm(rtc1.MATCH_SS);
rtc1.standbyMode(); // Sleep until next alarm match
`

@marcobrianza
Copy link
Contributor

I had similar periodic random issues and proposed this fix
#42

can you please try it?

@wjpavalko
Copy link

wjpavalko commented Jan 16, 2019 via email

@agdl agdl closed this as completed Apr 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants