-
Notifications
You must be signed in to change notification settings - Fork 78
Description
update1:
Problem solved, please see my last message in this string...
I expect this is also an issue with SAMD21 CPU chip...
update:
If I take a new processor chip, and run the program, it fails, but if I use a processor that has had the RTC register set by using the rtc.setHours(hours); etc function, it work as expected.
very odd...
just a note:
I'm testing the SAMD51 port by: ericbaril72 at: https://github.com/ericbaril72/RTCZero/tree/SAMD51_E54
In my test program below, if I run it on a SAMD21 processor, I get the expected results, if I set the time via a: rtc.setEpoch(1451606400); // Jan 1, 2016, it returns the expected: 01/01/16 00:00:00
But if I run it on a SAMD51 processor, it returns: 16/06/16 08:39:05
looks to be an issue in the SAMD51 port if setting time via rtc.setEpoch or ??
IDE 1.8.12
Feather M0 and M4 processors
/*
Simple RTC for Arduino Zero and MKR1000
Demonstrates the use of the RTC library for the Arduino Zero and MKR1000
This example code is in the public domain
http://arduino.cc/en/Tutorial/SimpleRTC
created by Arturo Guadalupi <[email protected]>
15 Jun 2015
modified
18 Feb 2016
modified by Andrea Richetta <[email protected]>
24 Aug 2016
*/
#include <RTCZero.h>
/* Create an rtc object */
RTCZero rtc;
void setup()
{
Serial.begin(9600);
rtc.begin(); // initialize RTC
// Set the time
rtc.setEpoch(1451606400); // Jan 1, 2016 00:00:00
}
void loop()
{
Serial.println(rtc.getEpoch());
// Print date...
print2digits(rtc.getDay());
Serial.print("/");
print2digits(rtc.getMonth());
Serial.print("/");
print2digits(rtc.getYear());
Serial.print(" ");
// ...and time
print2digits(rtc.getHours());
Serial.print(":");
print2digits(rtc.getMinutes());
Serial.print(":");
print2digits(rtc.getSeconds());
Serial.println();
delay(1000);
}
void print2digits(int number) {
if (number < 10) {
Serial.print("0"); // print a 0 before if the number is < than 10
}
Serial.print(number);
}