Skip to content

Commit 6592f36

Browse files
hannobraunYatekii
authored andcommitted
Fix weird timer edge case
1 parent 4c21ba5 commit 6592f36

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

nrf52-hal-common/src/timer.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ where
8989
where
9090
Time: Into<Self::Time>,
9191
{
92+
// If the following sequence of events occurs, the COMPARE event will be
93+
// set here:
94+
// 1. `start` is called.
95+
// 2. The timer runs out but `wait` is _not_ called.
96+
// 3. `start` is called again
97+
//
98+
// If that happens, then we need to reset the event here explicitly, as
99+
// nothing else this method does will reset the event, and if it's still
100+
// active after this method exits, then the next call to `wait` will
101+
// return immediately, no matter how much time has actually passed.
102+
self.0.events_compare[0].reset();
103+
92104
// Configure timer to trigger EVENTS_COMPARE when given number of cycles
93105
// is reached.
94106
self.0.cc[0].write(|w|

0 commit comments

Comments
 (0)