From c21a402ebcf26fd40a2809fc771b71a3e9b31962 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Fri, 21 Nov 2025 14:56:00 -0800 Subject: Fix clkdiv configuration DIV should be modified while the clock is halted, not after it's already running. --- src/clocks/mod.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/clocks/mod.rs') diff --git a/src/clocks/mod.rs b/src/clocks/mod.rs index a12e125c6..0b4535dc4 100644 --- a/src/clocks/mod.rs +++ b/src/clocks/mod.rs @@ -652,17 +652,15 @@ impl ClockOperator<'_> { }); } - // Halt and reset the div + // Halt and reset the div; then set our desired div. self.syscon.frohfdiv().write(|w| { w.halt().halt(); w.reset().asserted(); + unsafe { w.div().bits(d.into_bits()) }; w }); - // Then change the div, unhalt it, and reset it + // Then unhalt it, and reset it self.syscon.frohfdiv().write(|w| { - unsafe { - w.div().bits(d.into_bits()); - } w.halt().run(); w.reset().released(); w @@ -743,17 +741,15 @@ impl ClockOperator<'_> { }); } - // Halt and reset the div + // Halt and reset the div; then set our desired div. self.syscon.frolfdiv().write(|w| { w.halt().halt(); w.reset().asserted(); + unsafe { w.div().bits(d.into_bits()) }; w }); - // Then change the div, unhalt it, and reset it + // Then unhalt it, and reset it self.syscon.frolfdiv().write(|w| { - unsafe { - w.div().bits(d.into_bits()); - } w.halt().run(); w.reset().released(); w -- cgit