I am detecting a slight sluggishness in my board. For example when an upload is complete, the status bar pop-up indicating such lingers long after the sketch is running and serial is ticking along.
Also, the board is throwing up the red "SOS +1" blinky quite often. This most notably when I run the two RTC examples from the Cheat Sheet. For those two, it occurs at RTCSet();
, best I can figure. Two other similar examples from here also worked fine when I first got this board 4 weeks ago. When commenting line in setup()
for setting the RTC (//RTCSet();
), after upload, RTC resumes ticking along at the time I set four weeks ago. When uncommenting that line, the board crashes and sends out an "SOS+1".
(EDIT: What I mean by "resumes ticking along ..." is that the time has updated to current time, although is offset by an accrued 16 hour error from this board defaulting to the LSI oscillator. Yeah, so I am trying to reset the time to the present. I do have a coin battery attached and serving D3 power.)
What could have transpired in past 4 weeks that would lead to this vexing behaviour from the board? I take good care of my hardware, and believe I have good practices and habits. In the ten years I have fiddled with AVRs, only last month did I experience cindering a board by accidentally shorting an LDO across some pins on a ProMini. And I did not even get to see the blue genie in action.
Anyway, the offending RTC code from the Cheat Sheet is below. As an aside, when running the WiFi RTC example, can hook up my network, appears in Serial as such. Thank you for any advices you folks can offer.
#include "mbed.h"
#include <mbed_mktime.h>
constexpr unsigned long printInterval { 1000 };
unsigned long printNow {};
void setup() {
Serial.begin(9600);
RTCset();
}
void loop() {
if (millis() > printNow) {
Serial.print("System Clock: ");
Serial.println(getLocaltime());
printNow = millis() + printInterval;
}
}
void RTCset() // Set cpu RTC
{
tm t;
t.tm_sec = (0); // 0-59
t.tm_min = (47); // 0-59
t.tm_hour = (10); // 0-23
t.tm_mday = (12); // 1-31
t.tm_mon = (0); // 0-11 "0" = Jan, -1
t.tm_year = ((24)+100); // year since 1900, current year + 100 + 1900 = correct year
set_time(mktime(&t)); // set RTC clock
}
String getLocaltime()
{
char buffer[32];
tm t;
_rtc_localtime(time(NULL), &t, RTC_4_YEAR_LEAP_YEAR_SUPPORT);
strftime(buffer, 32, "%Y-%m-%d %k:%M:%S", &t);
return String(buffer);
}