Skip to content

Commit

Permalink
Fix MonoTimer
Browse files Browse the repository at this point in the history
DCB::enable_trace() has to be called,
so that DWT does work
  • Loading branch information
Sh3Rm4n committed Aug 1, 2021
1 parent 844f9a8 commit 0a16d09
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use core::convert::{From, TryFrom};

use cortex_m::peripheral::DWT;
use cortex_m::peripheral::{DCB, DWT};
#[cfg(feature = "enumset")]
use enumset::{EnumSet, EnumSetType};
use void::Void;
Expand Down Expand Up @@ -61,7 +61,9 @@ impl defmt::Format for MonoTimer {

impl MonoTimer {
/// Creates a new `Monotonic` timer
pub fn new(mut dwt: DWT, clocks: Clocks) -> Self {
pub fn new(mut dwt: DWT, clocks: Clocks, dcb: &mut DCB) -> Self {
// This is needed, so that the DWT timer starts to count.
dcb.enable_trace();
dwt.enable_cycle_counter();

// now the CYCCNT counter can't be stopped or resetted
Expand Down

0 comments on commit 0a16d09

Please sign in to comment.