M41T62 is a serial real-time clock (RTC) made by STMicroelectronics.

Dependents:   LPC1114_data_logger Check_external_RTC LPC1114_barometer_with_data_logging

Files at this revision

API Documentation at this revision

Comitter:
kenjiArai
Date:
Fri Aug 07 06:21:06 2020 +0000
Parent:
5:959683e91979
Commit message:
bug fix in set_alarm_reg

Changed in this revision

m41t62_rtc.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 959683e91979 -r 0bf0f681fb69 m41t62_rtc.cpp
--- a/m41t62_rtc.cpp	Fri Aug 07 05:39:14 2020 +0000
+++ b/m41t62_rtc.cpp	Fri Aug 07 06:21:06 2020 +0000
@@ -113,10 +113,8 @@
 {
     tm t;
     uint8_t m, h;
-    uint16_t set;
 
     read_rtc_std(&t);   // read current time
-    set = time + t.tm_hour * 60 + t.tm_min;
     m = t.tm_min + (uint8_t)(time % 60);
     h = t.tm_hour;
     if (m >= 60) {
@@ -137,8 +135,8 @@
     _i2c.write((int)M41T62_addr, (char *)rtc_buf, 2, false);
     // RPT4=1,RPT5=0,RPT3=0,RPT2=0,RPT1=0 & set day,hour,min,sec
     rtc_buf[4] = 0;                 // M41T62_REG_ALARM_SEC ->RPT=1, set 0sec
-    rtc_buf[3] = bin2bcd(m) & 0x3f; // M41T62_REG_ALARM_MIN ->RPT2=0
-    rtc_buf[2] = bin2bcd(h) & 0x7f; // M41T62_REG_ALARM_HOUR ->RPT3=0
+    rtc_buf[3] = bin2bcd(m) & 0x7f; // M41T62_REG_ALARM_MIN ->RPT2=0
+    rtc_buf[2] = bin2bcd(h) & 0x3f; // M41T62_REG_ALARM_HOUR ->RPT3=0
     rtc_buf[1] = 0xc0;              // M41T62_REG_ALARM_DAY ->RPT4=1,RPT5=1
     rtc_buf[0] = M41T62_REG_ALARM_DAY;
     _i2c.write((int)M41T62_addr, (char *)rtc_buf, 5, false);