Skip to content

Commit af8ca56

Browse files
committed
Should use core_clk for delay calculations
1 parent 107730c commit af8ca56

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/comparator.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ dac_input!(COMP2, dac::Channel2<dac::Enabled>, 0b0101);
232232

233233
pub struct Comparator<C> {
234234
regs: C,
235-
pclk: Hertz,
235+
sysclk: Hertz,
236236
}
237237

238238
pub trait ComparatorExt<COMP> {
@@ -265,7 +265,7 @@ macro_rules! comparator_ext {
265265
positive_input.setup(&self.regs);
266266
negative_input.setup(&self.regs);
267267
// Delay for scaler voltage bridge initialization for certain negative inputs
268-
let voltage_scaler_delay = self.pclk.0 / (1_000_000 / 200); // 200us
268+
let voltage_scaler_delay = self.sysclk.0 / (1_000_000 / 200); // 200us
269269
cortex_m::asm::delay(voltage_scaler_delay);
270270
self.regs.csr().modify(|_, w| unsafe {
271271
w.hyst()
@@ -429,16 +429,16 @@ pub fn split(_comp: COMP, rcc: &mut Rcc) -> (Comparator<COMP1>, Comparator<COMP2
429429
rcc.rb.apbrstr2.modify(|_, w| w.syscfgrst().clear_bit());
430430

431431
// Used to calculate delays for initialization
432-
let pclk = rcc.clocks.apb_clk;
432+
let sysclk = rcc.clocks.core_clk;
433433

434434
(
435435
Comparator {
436436
regs: COMP1 { _rb: PhantomData },
437-
pclk,
437+
sysclk,
438438
},
439439
Comparator {
440440
regs: COMP2 { _rb: PhantomData },
441-
pclk,
441+
sysclk,
442442
},
443443
)
444444
}

0 commit comments

Comments
 (0)