Skip to content

Commit

Permalink
[board] Correcly enable overdrive mode for STM32 boards with >=180 MH…
Browse files Browse the repository at this point in the history
…z clock
  • Loading branch information
chris-durand authored and salkinium committed Jan 10, 2021
1 parent cbaf940 commit 02b1571
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/modm/board/disco_f429zi/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ struct SystemClock
.pllP = 2 // 360MHz / P=2 -> 180MHz = F_cpu
};
Rcc::enablePll(Rcc::PllSource::ExternalCrystal, pllFactors);
PWR->CR |= PWR_CR_ODEN; // Enable overdrive mode
while (not (PWR->CSR & PWR_CSR_ODRDY)) ;
// Required for 180 MHz clock
Rcc::enableOverdriveMode();
Rcc::setFlashLatency<Frequency>();
Rcc::enableSystemClock(Rcc::SystemClockSource::Pll);
Rcc::setApb1Prescaler(Rcc::Apb1Prescaler::Div4);
Expand Down
4 changes: 2 additions & 2 deletions src/modm/board/disco_f469ni/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ struct SystemClock
.pllP = 2, // 360MHz / P=2 -> 180MHz = F_cpu
};
Rcc::enablePll(Rcc::PllSource::ExternalCrystal, pllFactors);
PWR->CR |= PWR_CR_ODEN; // Enable overdrive mode
while (not (PWR->CSR & PWR_CSR_ODRDY)) ;
// Required for 180 MHz clock
Rcc::enableOverdriveMode();
Rcc::setFlashLatency<Frequency>();
Rcc::enableSystemClock(Rcc::SystemClockSource::Pll);
Rcc::setApb1Prescaler(Rcc::Apb1Prescaler::Div4);
Expand Down
4 changes: 2 additions & 2 deletions src/modm/board/disco_f746ng/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ struct SystemClock
.pllQ = 9 // 432MHz / Q=9 -> 48MHz = F_usb
};
Rcc::enablePll(Rcc::PllSource::ExternalClock, pllFactors);
PWR->CR1 |= PWR_CR1_ODEN; // Enable overdrive mode
while (not (PWR->CSR1 & PWR_CSR1_ODRDY)) ;
// Required for 216 MHz clock
Rcc::enableOverdriveMode();

Rcc::setFlashLatency<Frequency>();
Rcc::enableSystemClock(Rcc::SystemClockSource::Pll);
Expand Down
4 changes: 2 additions & 2 deletions src/modm/board/disco_f769ni/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ struct SystemClock
.pllP = 2 // 432MHz / P=2 -> 216MHz = F_cpu
};
Rcc::enablePll(Rcc::PllSource::ExternalClock, pllFactors);
PWR->CR1 |= PWR_CR1_ODEN; // Enable overdrive mode
while (not (PWR->CSR1 & PWR_CSR1_ODRDY)) ;
// Required for 216 MHz clock
Rcc::enableOverdriveMode();
Rcc::setFlashLatency<Frequency>();
Rcc::enableSystemClock(Rcc::SystemClockSource::Pll);
// APB1 is running only at 27MHz, since AHB / 4 = 54MHz > 45MHz limit!
Expand Down
2 changes: 2 additions & 0 deletions src/modm/board/nucleo_f446re/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ struct SystemClock {
.pllP = 2, // 360MHz / P= 2 -> 180MHz = F_cpu
};
Rcc::enablePll(Rcc::PllSource::InternalClock, pllFactors);
// Required for 180 MHz clock
Rcc::enableOverdriveMode();
// set flash latency
Rcc::setFlashLatency<Frequency>();
// switch system clock to PLL output
Expand Down
4 changes: 2 additions & 2 deletions src/modm/board/nucleo_f746zg/board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ struct SystemClock
//.pllQ = 9 // 432MHz / P=2 -> 48MHz (USB, etc.)
};
Rcc::enablePll(Rcc::PllSource::ExternalClock, pllFactors);
PWR->CR1 |= PWR_CR1_ODEN; // Enable overdrive mode
while (not (PWR->CSR1 & PWR_CSR1_ODRDY)) ;
// Required for 216 MHz clock
Rcc::enableOverdriveMode();
Rcc::setFlashLatency<Frequency>();
Rcc::enableSystemClock(Rcc::SystemClockSource::Pll);
// APB1 is running at 54MHz, since AHB / 4 = 54MHz (= limit)
Expand Down

0 comments on commit 02b1571

Please sign in to comment.