diff --git a/CHANGELOG.md b/CHANGELOG.md index 39a92bf9..5bb886f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed +- Fix hclk miscalculation + ## [v0.3.0] - 2019-04-27 ### Added diff --git a/src/rcc.rs b/src/rcc.rs index b826b306..d9bf8c78 100644 --- a/src/rcc.rs +++ b/src/rcc.rs @@ -204,7 +204,11 @@ impl CFGR { }) .unwrap_or(0b0111); - let hclk = sysclk / (1 << (hpre_bits - 0b0111)); + let hclk = if hpre_bits >= 0b1100 { + sysclk / (1 << (hpre_bits - 0b0110)) + } else { + sysclk / (1 << (hpre_bits - 0b0111)) + }; assert!(hclk <= 72_000_000);