Skip to content

Commit 2367482

Browse files
committed
Workaround to fix RTC-reset issue on the EFM32GG11_STK3701
1 parent 22d926f commit 2367482

File tree

1 file changed

+11
-1
lines changed
  • targets/TARGET_Silicon_Labs/TARGET_EFM32

1 file changed

+11
-1
lines changed

targets/TARGET_Silicon_Labs/TARGET_EFM32/rtcc.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,20 @@ void rtc_init(void)
5151
RMU_ResetControl(rmuResetPin, rmuResetModeFull);
5252

5353
/* Set up the RTCC and let it run, Forrest, run */
54+
55+
//Save time if it has been set.
56+
time_t t = 0;
57+
if (RTCC->RET[1].REG == 0) t = rtc_read();
58+
5459
RTCC_Reset();
5560
RTCC_Init_TypeDef rtcc_init = RTCC_INIT_DEFAULT;
5661
rtcc_init.presc = rtccCntPresc_32768;
5762
RTCC_Init(&rtcc_init);
5863
RTCC_Enable(true);
59-
RTCC->RET[0].REG = 0;
64+
65+
//Update time
66+
if (RTCC->RET[1].REG == 0) rtc_write(t);
67+
else RTCC->RET[0].REG = 0;
6068
}
6169

6270
void rtc_free(void)
@@ -79,6 +87,8 @@ void rtc_write(time_t t)
7987
{
8088
core_util_critical_section_enter();
8189
RTCC->RET[0].REG = t - RTCC_CounterGet();
90+
//Record that the time has been set
91+
RTCC->RET[1].REG = 0;
8292
core_util_critical_section_exit();
8393
}
8494

0 commit comments

Comments
 (0)