From a03052355efd58adec27240e42ce58ba3a9f5dbf Mon Sep 17 00:00:00 2001 From: Derek Witt Date: Sun, 8 Aug 2021 23:47:50 -0400 Subject: [PATCH] Correctly configure watchdog tick generation (#78) Fix: The divider for watchdog tick generation is now being set to the source clock frequency in MHz, instead of the clock frequency in Hz. Watchdog ticks will now be generated at 1 microsecond intervals as intended. --- rp2040-hal/src/clocks/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rp2040-hal/src/clocks/mod.rs b/rp2040-hal/src/clocks/mod.rs index 5109f31..cf68005 100644 --- a/rp2040-hal/src/clocks/mod.rs +++ b/rp2040-hal/src/clocks/mod.rs @@ -316,8 +316,8 @@ pub fn init_clocks_and_plls( ) -> Result { let xosc = setup_xosc_blocking(xosc_dev, xosc_crystal_freq.Hz()).map_err(InitError::XoscErr)?; - // Start tick in watchdog - watchdog.enable_tick_generation(xosc_crystal_freq as u8); + // Configure watchdog tick generation to tick over every microsecond + watchdog.enable_tick_generation((xosc_crystal_freq / 1_000_000) as u8); let mut clocks = ClocksManager::new(clocks_dev);