File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 28
28
//! ```
29
29
30
30
use core:: ops;
31
- use cortex_m:: peripheral:: DWT ;
31
+ use cortex_m:: peripheral:: { DCB , DWT } ;
32
32
33
33
use crate :: rcc:: Clocks ;
34
34
@@ -227,14 +227,20 @@ impl_arithmetic!(MegaHertz, u32);
227
227
impl_arithmetic ! ( Bps , u32 ) ;
228
228
229
229
/// A monotonic non-decreasing timer
230
+ ///
231
+ /// This uses the timer in the debug watch trace peripheral. This means, that if the
232
+ /// core is stopped, the timer does not count up. This may be relevant if you are using
233
+ /// cortex_m_semihosting::hprintln for debugging in which case the timer will be stopped
234
+ /// while printing
230
235
#[ derive( Clone , Copy ) ]
231
236
pub struct MonoTimer {
232
237
frequency : Hertz ,
233
238
}
234
239
235
240
impl MonoTimer {
236
241
/// Creates a new `Monotonic` timer
237
- pub fn new ( mut dwt : DWT , clocks : Clocks ) -> Self {
242
+ pub fn new ( mut dwt : DWT , mut dcb : DCB , clocks : Clocks ) -> Self {
243
+ dcb. enable_trace ( ) ;
238
244
dwt. enable_cycle_counter ( ) ;
239
245
240
246
// now the CYCCNT counter can't be stopped or reset
You can’t perform that action at this time.
0 commit comments