Browse Source

Fix mono_timer not counting up without debugger connected

TheZoq2 3 years ago
parent
commit
731b94db5c
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/time.rs

+ 3 - 2
src/time.rs

@@ -28,7 +28,7 @@
 //! ```
 
 use core::ops;
-use cortex_m::peripheral::DWT;
+use cortex_m::peripheral::{DWT, DCB};
 
 use crate::rcc::Clocks;
 
@@ -234,7 +234,8 @@ pub struct MonoTimer {
 
 impl MonoTimer {
     /// Creates a new `Monotonic` timer
-    pub fn new(mut dwt: DWT, clocks: Clocks) -> Self {
+    pub fn new(mut dwt: DWT, mut dcb: DCB, clocks: Clocks) -> Self {
+        dcb.enable_trace();
         dwt.enable_cycle_counter();
 
         // now the CYCCNT counter can't be stopped or reset