Skip to content

Commit 2cb4d4a

Browse files
kilograhamReneg973
andauthored
Add delay to hello_rtc (#109) (#215)
A delay is needed after `rtc_set_datetime()` before the newly set value can be read back. Co-authored-by: Rene Greiner <[email protected]>
1 parent 4039929 commit 2cb4d4a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

rtc/hello_rtc/hello_rtc.c

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ int main() {
3232
rtc_init();
3333
rtc_set_datetime(&t);
3434

35+
// clk_sys is >2000x faster than clk_rtc, so datetime is not updated immediately when rtc_get_datetime() is called.
36+
// tbe delay is up to 3 RTC clock cycles (which is 64us with the default clock settings)
37+
sleep_us(64);
38+
3539
// Print the time
3640
while (true) {
3741
rtc_get_datetime(&t);

0 commit comments

Comments
 (0)