Merge pull request #15223 from aabadie/pr/cpu/stm32f4f7_overdrive_en

cpu/stm32: enable overdrive mode on f4 and f7 for high clock speeds
This commit is contained in:
benpicco 2020-10-15 14:49:38 +02:00 committed by GitHub
commit be261f0138
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -479,6 +479,25 @@ void stmclk_init_sysclk(void)
/* Flash config */ /* Flash config */
FLASH->ACR = FLASH_ACR_CONFIG; FLASH->ACR = FLASH_ACR_CONFIG;
/* Enable Over-Drive if HCLK > 168MHz on F4 or HCLK > 180MHz on F7 */
#if defined(CPU_FAM_STM32F4) && defined(PWR_CR_ODEN)
if (CLOCK_AHB > MHZ(168)) {
PWR->CR |= PWR_CR_ODEN;
while (!(PWR->CSR & PWR_CSR_ODRDY)) {}
PWR->CR |= PWR_CR_ODSWEN;
while (!(PWR->CSR & PWR_CSR_ODSWRDY)) {}
}
#endif
#if defined(CPU_FAM_STM32F7)
if (CLOCK_AHB > MHZ(180)) {
PWR->CR1 |= PWR_CR1_ODEN;
while (!(PWR->CSR1 & PWR_CSR1_ODRDY)) {}
PWR->CR1 |= PWR_CR1_ODSWEN;
while (!(PWR->CSR1 & PWR_CSR1_ODSWRDY)) {}
}
#endif
/* disable all active clocks except HSI -> resets the clk configuration */ /* disable all active clocks except HSI -> resets the clk configuration */
RCC->CR = (RCC_CR_HSION | RCC_CR_HSITRIM_4); RCC->CR = (RCC_CR_HSION | RCC_CR_HSITRIM_4);