aboutsummaryrefslogtreecommitdiff
path: root/src/clocks/mod.rs
diff options
context:
space:
mode:
authorFelipe Balbi <[email protected]>2025-11-21 14:56:00 -0800
committerFelipe Balbi <[email protected]>2025-11-21 15:03:23 -0800
commitc21a402ebcf26fd40a2809fc771b71a3e9b31962 (patch)
tree2b59cec3cc2b0e369c22d49d13bdbf8233308b66 /src/clocks/mod.rs
parentafbf72fb7842c926a9ac9b62f794ed010d4f7b27 (diff)
Fix clkdiv configuration
DIV should be modified while the clock is halted, not after it's already running.
Diffstat (limited to 'src/clocks/mod.rs')
-rw-r--r--src/clocks/mod.rs16
1 files changed, 6 insertions, 10 deletions
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<'_> {
652 }); 652 });
653 } 653 }
654 654
655 // Halt and reset the div 655 // Halt and reset the div; then set our desired div.
656 self.syscon.frohfdiv().write(|w| { 656 self.syscon.frohfdiv().write(|w| {
657 w.halt().halt(); 657 w.halt().halt();
658 w.reset().asserted(); 658 w.reset().asserted();
659 unsafe { w.div().bits(d.into_bits()) };
659 w 660 w
660 }); 661 });
661 // Then change the div, unhalt it, and reset it 662 // Then unhalt it, and reset it
662 self.syscon.frohfdiv().write(|w| { 663 self.syscon.frohfdiv().write(|w| {
663 unsafe {
664 w.div().bits(d.into_bits());
665 }
666 w.halt().run(); 664 w.halt().run();
667 w.reset().released(); 665 w.reset().released();
668 w 666 w
@@ -743,17 +741,15 @@ impl ClockOperator<'_> {
743 }); 741 });
744 } 742 }
745 743
746 // Halt and reset the div 744 // Halt and reset the div; then set our desired div.
747 self.syscon.frolfdiv().write(|w| { 745 self.syscon.frolfdiv().write(|w| {
748 w.halt().halt(); 746 w.halt().halt();
749 w.reset().asserted(); 747 w.reset().asserted();
748 unsafe { w.div().bits(d.into_bits()) };
750 w 749 w
751 }); 750 });
752 // Then change the div, unhalt it, and reset it 751 // Then unhalt it, and reset it
753 self.syscon.frolfdiv().write(|w| { 752 self.syscon.frolfdiv().write(|w| {
754 unsafe {
755 w.div().bits(d.into_bits());
756 }
757 w.halt().run(); 753 w.halt().run();
758 w.reset().released(); 754 w.reset().released();
759 w 755 w