halleffector
Member
I know the DS1302 is not the best RTC, but mine shows the following serial output:
As can be seen from the output, it appears to keep accurate time, just that every other read returns garbage!
I tried to change the latency to nothing, but then all reads are garbage. I also tried changing the latency to 2 seconds, but this also results in all reads becoming garbage.
Is this normal behavior from the DS1302? Is it simply that bad?
I'm using the following code, which I simply found online, it was originally intended to drive an LCD, but I've simply modified it to serial output:
Code:
DS1302 RTC test.
00:00:00
16:07:01
00:00:00
16:07:03
00:00:00
16:07:05
00:00:00
16:07:07
00:00:00
16:07:09
As can be seen from the output, it appears to keep accurate time, just that every other read returns garbage!
I tried to change the latency to nothing, but then all reads are garbage. I also tried changing the latency to 2 seconds, but this also results in all reads becoming garbage.
Is this normal behavior from the DS1302? Is it simply that bad?
I'm using the following code, which I simply found online, it was originally intended to drive an LCD, but I've simply modified it to serial output:
Code:
// DS1302: RST pin -> Arduino Digital 4
// DATA pin -> Arduino Digital 3
// CLK pin -> Arduino Digital 2
#include <DS1302.h>
#include <Wire.h>
DS1302 rtc(4, 3, 2);
void setup()
{
Serial.begin(9600);
Serial.println("DS1302 RTC test.");
// Set the clock to run-mode, and disable the write protection
rtc.halt(false);
rtc.writeProtect(false);
// The following lines can be commented out to use the values already stored in the DS1302
rtc.setDOW(WEDNESDAY); // Set Day-of-Week to FRIDAY
rtc.setTime(16, 7, 0); // Set the time to 12:00:00 (24hr format)
rtc.setDate(27, 1, 2016); // Set the date to August 6th, 2010
rtc.writeProtect(true);
}
void loop()
{
Serial.println(rtc.getTimeStr());
// Serial.println(rtc.getDOWStr(FORMAT_SHORT));
// Serial.println(rtc.getDateStr());
delay (1000);
}