@@ -39,8 +39,7 @@ const SYST_CALIB_NOREF: u32 = 1 << 31;
39
39
impl SYST {
40
40
/// Clears current value to 0
41
41
///
42
- /// After calling `clear_current()`, the next call to `has_wrapped()`
43
- /// will return `false`.
42
+ /// After calling `clear_current()`, the next call to `has_wrapped()` will return `false`.
44
43
pub fn clear_current ( & mut self ) {
45
44
unsafe { self . cvr . write ( 0 ) }
46
45
}
@@ -56,6 +55,17 @@ impl SYST {
56
55
}
57
56
58
57
/// Enables counter
58
+ ///
59
+ /// *NOTE* The reference manual indicates that:
60
+ ///
61
+ /// "The SysTick counter reload and current value are undefined at reset, the correct
62
+ /// initialization sequence for the SysTick counter is:
63
+ ///
64
+ /// - Program reload value
65
+ /// - Clear current value
66
+ /// - Program Control and Status register"
67
+ ///
68
+ /// The sequence translates to `self.set_reload(x); self.clear_current(); self.enable_counter()`
59
69
pub fn enable_counter ( & mut self ) {
60
70
unsafe { self . csr . modify ( |v| v | SYST_CSR_ENABLE ) }
61
71
}
@@ -153,6 +163,8 @@ impl SYST {
153
163
/// Sets reload value
154
164
///
155
165
/// Valid values are between `1` and `0x00ffffff`.
166
+ ///
167
+ /// *NOTE* To make the timer wrap every `N` ticks set the reload value to `N - 1`
156
168
pub fn set_reload ( & mut self , value : u32 ) {
157
169
unsafe { self . rvr . write ( value) }
158
170
}
0 commit comments