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 <reneg973@gmail.com>
This commit is contained in:
Graham Sanderson 2022-05-17 13:11:57 -05:00 committed by GitHub
parent 4039929324
commit 2cb4d4aa1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,6 +32,10 @@ int main() {
rtc_init();
rtc_set_datetime(&t);
// clk_sys is >2000x faster than clk_rtc, so datetime is not updated immediately when rtc_get_datetime() is called.
// tbe delay is up to 3 RTC clock cycles (which is 64us with the default clock settings)
sleep_us(64);
// Print the time
while (true) {
rtc_get_datetime(&t);