From d77724bf046b128093be569e90b5c8d7593350d0 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Tue, 31 May 2022 15:26:22 +0200 Subject: [PATCH] cpu/sam0_common: RTC: wait for syncbusy in rtc_get_time() `rtt_get_counter()` already waits for syncbusy before reading the time, but we also have to do this in RTC mode (`rtc_get_time()`) to avoid reading old values. Thus, always wait for syncbusy to clear when accessing the COUNT register. --- cpu/sam0_common/periph/rtc_rtt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cpu/sam0_common/periph/rtc_rtt.c b/cpu/sam0_common/periph/rtc_rtt.c index 3d3d1f1b52..cda8c44240 100644 --- a/cpu/sam0_common/periph/rtc_rtt.c +++ b/cpu/sam0_common/periph/rtc_rtt.c @@ -90,8 +90,8 @@ static void _read_req(void) { #ifdef RTC_READREQ_RREQ RTC->MODE0.READREQ.reg = RTC_READREQ_RREQ; - _wait_syncbusy(); #endif + _wait_syncbusy(); } #endif @@ -644,7 +644,6 @@ void rtt_clear_overflow_cb(void) uint32_t rtt_get_counter(void) { - _wait_syncbusy(); _read_req(); return RTC->MODE0.COUNT.reg; }