diff options
| author | Russell Sim <russell.sim@gmail.com> | 2020-05-26 07:33:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-26 07:33:18 +0200 |
| commit | 7266ffe3a655f87f8c55d6db6f138c569b31b74a (patch) | |
| tree | e4fd7578270991a29fcc860d91853912333c61f6 /examples/periodic.rs | |
| parent | 7406f77a4ec163165fa2f89e8e9351b792e305e3 (diff) | |
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
Diffstat (limited to 'examples/periodic.rs')
| -rw-r--r-- | examples/periodic.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/periodic.rs b/examples/periodic.rs index dca0ad5..3d32bc2 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])] |
