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 2828//! ```
2929
3030use core:: ops;
31- use cortex_m:: peripheral:: DWT ;
31+ use cortex_m:: peripheral:: { DCB , DWT } ;
3232
3333use crate :: rcc:: Clocks ;
3434
@@ -227,14 +227,20 @@ impl_arithmetic!(MegaHertz, u32);
227227impl_arithmetic ! ( Bps , u32 ) ;
228228
229229/// 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
230235#[ derive( Clone , Copy ) ]
231236pub struct MonoTimer {
232237 frequency : Hertz ,
233238}
234239
235240impl MonoTimer {
236241 /// 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 ( ) ;
238244 dwt. enable_cycle_counter ( ) ;
239245
240246 // now the CYCCNT counter can't be stopped or reset
You can’t perform that action at this time.
0 commit comments