From 61262923d64500b26d877e61e3e8ed28e198ae18 Mon Sep 17 00:00:00 2001 From: woutervdhof Date: Sun, 26 Jan 2025 09:06:58 +0100 Subject: [PATCH] silicon errata issue 3 & 4 workaround (#68) --- src/MCP7940.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/MCP7940.cpp b/src/MCP7940.cpp index b313881..e935de6 100644 --- a/src/MCP7940.cpp +++ b/src/MCP7940.cpp @@ -69,7 +69,7 @@ DateTime::DateTime(uint32_t t) { t /= 60; mm = t % 60; t /= 60; - hh = t % 24; + hh = t % 24; uint16_t days = t / 24; uint8_t leap; for (yOff = 0;; ++yOff) { @@ -437,10 +437,11 @@ void MCP7940_Class::adjust(const DateTime& dt) { I2C_write(MCP7940_RTCMIN, int2bcd(dt.minute())); I2C_write(MCP7940_RTCHOUR, int2bcd(dt.hour())); weekdayWrite(dt.dayOfTheWeek()); // Update the weekday - I2C_write(MCP7940_RTCDATE, int2bcd(dt.day())); // Write the day of month I2C_write(MCP7940_RTCMTH, int2bcd(dt.month())); // Month, ignore R/O leapyear bit + I2C_write(MCP7940_RTCDATE, int2bcd(dt.day())); // Write the day of month I2C_write(MCP7940_RTCYEAR, int2bcd(dt.year() - 2000)); // Write the year deviceStart(); // Restart the oscillator + weekdayWrite(dt.dayOfTheWeek()); // Silicon errata issue 4 _SetUnixTime = dt.unixtime(); // Store time of last change } // of method adjust uint8_t MCP7940_Class::weekdayRead() const {