Hi Crenn,
Thanks so much for the response. I'm using the The ChronoDot RTC which uses the DS3231 chip with internal crystal. From the retailers websight:
"The I2C interface is very straightforward and virtually identical to the register addresses of the popular DS1337 and DS1307 RTCs, which means that existing code for the Arduino, Basic Stamp, Cubloc, and other controllers should work with no modification."
I've been using this RTC with good success on an Arduino UNO. I've been trying to get it working on the Maple r5 using pin 5 for SCL and pin 9 for SDA using the default Wire library and the following code:
#include <Wire.h>
void setup()
{
Wire.begin();
// clear /EOSC bit
// Sometimes necessary to ensure that the clock
// keeps running on just battery power. Once set,
// it shouldn't need to be reset but it's a good
// idea to make sure.
Wire.beginTransmission(0x68); // address DS3231
Wire.send(0x0E); // select register
Wire.send(0b00011100); // write register bitmap, bit 7 is /EOSC
Wire.endTransmission();
}
void loop()
{
// send request to receive data starting at register 0
Wire.beginTransmission(0x68); // 0x68 is DS3231 device address
Wire.send(0); // start at register 0
Wire.endTransmission();
Wire.requestFrom(0x68, 3); // request three bytes (seconds, minutes, hours)
//while(Wire.available())
{
int seconds = Wire.receive(); // get seconds
int minutes = Wire.receive(); // get minutes
int hours = Wire.receive(); // get hours
seconds = (((seconds & 0b11110000)>>4)*10 + (seconds & 0b00001111)); // convert BCD to decimal
minutes = (((minutes & 0b11110000)>>4)*10 + (minutes & 0b00001111)); // convert BCD to decimal
hours = (((hours & 0b00100000)>>5)*20 + ((hours & 0b00010000)>>4)*10 + (hours & 0b00001111)); // convert BCD to decimal (assume 24 hour mode)
SerialUSB.print(hours); SerialUSB.print(":"); SerialUSB.print(minutes); SerialUSB.print(":"); SerialUSB.println(seconds);
}
delay(1000);
}
Any feedback would be very much appreciated!
Cheers