diff --git a/rp2040-hal/CHANGELOG.md b/rp2040-hal/CHANGELOG.md index 77a1da894..62b26e494 100644 --- a/rp2040-hal/CHANGELOG.md +++ b/rp2040-hal/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +## Fixed + +- Fixed minimum PLL's VCO frequency according to updated datasheet - @ithinuel + ## [0.9.0] ### MSRV diff --git a/rp2040-hal/src/pll.rs b/rp2040-hal/src/pll.rs index aae025d4d..f79e1f507 100644 --- a/rp2040-hal/src/pll.rs +++ b/rp2040-hal/src/pll.rs @@ -127,10 +127,10 @@ pub mod common_configs { /// Default, nominal configuration for PLL_USB. pub const PLL_USB_48MHZ: PLLConfig = PLLConfig { - vco_freq: HertzU32::MHz(480), + vco_freq: HertzU32::MHz(960), refdiv: 1, post_div1: 5, - post_div2: 2, + post_div2: 4, }; } @@ -141,18 +141,22 @@ impl PhaseLockedLoop { xosc_frequency: HertzU32, config: PLLConfig, ) -> Result, Error> { - const VCO_FREQ_RANGE: RangeInclusive = HertzU32::MHz(400)..=HertzU32::MHz(1_600); + const VCO_FREQ_RANGE: RangeInclusive = HertzU32::MHz(750)..=HertzU32::MHz(1_600); const POSTDIV_RANGE: Range = 1..7; const FBDIV_RANGE: Range = 16..320; - let vco_freq = config.vco_freq; + let PLLConfig { + vco_freq, + refdiv, + post_div1, + post_div2, + } = config; if !VCO_FREQ_RANGE.contains(&vco_freq) { return Err(Error::VcoFreqOutOfRange); } - if !POSTDIV_RANGE.contains(&config.post_div1) || !POSTDIV_RANGE.contains(&config.post_div2) - { + if !POSTDIV_RANGE.contains(&post_div1) || !POSTDIV_RANGE.contains(&post_div2) { return Err(Error::PostDivOutOfRage); } @@ -161,7 +165,7 @@ impl PhaseLockedLoop { let ref_freq_hz: HertzU32 = xosc_frequency .to_Hz() - .checked_div(u32::from(config.refdiv)) + .checked_div(u32::from(refdiv)) .ok_or(Error::BadArgument)? .Hz(); @@ -180,9 +184,6 @@ impl PhaseLockedLoop { return Err(Error::FeedbackDivOutOfRange); } - let refdiv = config.refdiv; - let post_div1 = config.post_div1; - let post_div2 = config.post_div2; let frequency: HertzU32 = ((ref_freq_hz / u32::from(refdiv)) * u32::from(fbdiv)) / (u32::from(post_div1) * u32::from(post_div2));