Browse Source

F7_HAL/rcc: Adjust computation of SYSCLK to retain precision.

work-f1-1.10.2
Damien George 7 years ago
committed by Damien George
parent
commit
d23f17fccc
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc.c

+ 6
- 1
STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc.c View File

@@ -917,7 +917,12 @@ uint32_t HAL_RCC_GetSysClockFreq(void)
if (__HAL_RCC_GET_PLL_OSCSOURCE() != RCC_PLLCFGR_PLLSRC_HSI)
{
/* HSE used as PLL clock source */
pllvco = ((HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> POSITION_VAL(RCC_PLLCFGR_PLLN)));
//pllvco = ((HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> POSITION_VAL(RCC_PLLCFGR_PLLN)));
// dpgeorge: Adjust the way the arithmetic is done so it retains
// precision for the case that pllm doesn't evenly divide HSE_VALUE.
// Must be sure not to overflow, so divide by 4 first. HSE_VALUE
// should be a multiple of 4 (being a multiple of 100 is enough).
pllvco = ((HSE_VALUE / 4) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> POSITION_VAL(RCC_PLLCFGR_PLLN))) / pllm * 4;
}
else
{


Loading…
Cancel
Save