Skip to content

Commit ac98e3d

Browse files
authored
Merge pull request #44 from jetty840/master
Calling setEpoch causes serial data / interrupts to be lost
2 parents 7ab52e2 + 3eae0f5 commit ac98e3d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/RTCZero.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -421,12 +421,16 @@ void RTCZero::setEpoch(uint32_t ts)
421421
time_t t = ts;
422422
struct tm* tmp = gmtime(&t);
423423

424-
RTC->MODE2.CLOCK.bit.YEAR = tmp->tm_year - EPOCH_TIME_YEAR_OFF;
425-
RTC->MODE2.CLOCK.bit.MONTH = tmp->tm_mon + 1;
426-
RTC->MODE2.CLOCK.bit.DAY = tmp->tm_mday;
427-
RTC->MODE2.CLOCK.bit.HOUR = tmp->tm_hour;
428-
RTC->MODE2.CLOCK.bit.MINUTE = tmp->tm_min;
429-
RTC->MODE2.CLOCK.bit.SECOND = tmp->tm_sec;
424+
RTC_MODE2_CLOCK_Type clockTime;
425+
426+
clockTime.bit.YEAR = tmp->tm_year - EPOCH_TIME_YEAR_OFF;
427+
clockTime.bit.MONTH = tmp->tm_mon + 1;
428+
clockTime.bit.DAY = tmp->tm_mday;
429+
clockTime.bit.HOUR = tmp->tm_hour;
430+
clockTime.bit.MINUTE = tmp->tm_min;
431+
clockTime.bit.SECOND = tmp->tm_sec;
432+
433+
RTC->MODE2.CLOCK.reg = clockTime.reg;
430434

431435
while (RTCisSyncing())
432436
;

0 commit comments

Comments
 (0)