We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 6855541 + 62d7a80 commit dd0f868Copy full SHA for dd0f868
1 file changed
ports/atmel-samd/common-hal/rtc/RTC.c
@@ -64,6 +64,12 @@ void common_hal_rtc_get_time(timeutils_struct_time_t *tm) {
64
}
65
66
void common_hal_rtc_set_time(timeutils_struct_time_t *tm) {
67
+ // Reset prescaler to increase initial precision. Otherwise we can be up to 1 second off already.
68
+ uint32_t freqcorr = hri_rtcmode0_read_FREQCORR_reg(calendar.device.hw);
69
+ calendar_deinit(&calendar);
70
+ rtc_init();
71
+ hri_rtcmode0_write_FREQCORR_reg(calendar.device.hw, freqcorr);
72
+
73
struct calendar_date date = {
74
.year = tm->tm_year,
75
.month = tm->tm_mon,
0 commit comments