From 7266ffe3a655f87f8c55d6db6f138c569b31b74a Mon Sep 17 00:00:00 2001 From: Russell Sim Date: Tue, 26 May 2020 07:33:18 +0200 Subject: [PATCH] Update example to use better initial value The example above this in the documentation states ``` // semantically, the monotonic timer is frozen at time "zero" during `init` // NOTE do *not* call `Instant::now` in this context; it will return a nonsense value let now = cx.start; // the start time of the system ``` It results in weird scheduling issues, but still eventually works. `cx.start` is much more reliable. Relates to https://github.com/rtfm-rs/cortex-m-rtfm/issues/196 --- examples/periodic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/periodic.rs b/examples/periodic.rs index dca0ad565b..3d32bc21ad 100644 --- a/examples/periodic.rs +++ b/examples/periodic.rs @@ -18,7 +18,7 @@ const APP: () = { fn init(cx: init::Context) { // omitted: initialization of `CYCCNT` - cx.schedule.foo(Instant::now() + PERIOD.cycles()).unwrap(); + cx.schedule.foo(cx.start + PERIOD.cycles()).unwrap(); } #[task(schedule = [foo])]