File tree Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77
88## [ Unreleased]
99
10+ ### Changed
11+
12+ - Wait 16 cycles after setting prescalers for some clock domains to follow manual.
13+
1014## [ v0.7.0] - 2020-03-07
1115
1216### Changed
Original file line number Diff line number Diff line change @@ -353,22 +353,29 @@ impl CFGR {
353353 while rcc. cr . read ( ) . pllrdy ( ) . bit_is_clear ( ) { }
354354 }
355355
356- // Set scaling factors and select system clock source
356+ // Set scaling factors
357357 rcc. cfgr . modify ( |_, w| unsafe {
358358 w. ppre2 ( )
359359 . bits ( ppre2_bits)
360360 . ppre1 ( )
361361 . bits ( ppre1_bits)
362362 . hpre ( )
363363 . variant ( hpre_bits)
364- . sw ( )
365- . variant ( if sysclk_on_pll {
366- SW_A :: PLL
367- } else if self . hse . is_some ( ) {
368- SW_A :: HSE
369- } else {
370- SW_A :: HSI
371- } )
364+ } ) ;
365+
366+ // Wait for the new prescalers to kick in
367+ // "The clocks are divided with the new prescaler factor from 1 to 16 AHB cycles after write"
368+ cortex_m:: asm:: delay ( 16 ) ;
369+
370+ // Select system clock source
371+ rcc. cfgr . modify ( |_, w| {
372+ w. sw ( ) . variant ( if sysclk_on_pll {
373+ SW_A :: PLL
374+ } else if self . hse . is_some ( ) {
375+ SW_A :: HSE
376+ } else {
377+ SW_A :: HSI
378+ } )
372379 } ) ;
373380
374381 let clocks = Clocks {
You can’t perform that action at this time.
0 commit comments