Skip to content

Commit af9d885

Browse files
dhylandsdpgeorge
authored andcommitted
stmhal: Port of f4 hal commit c568a2b to f7 hal
1 parent 9e8eba7 commit af9d885

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

stmhal/hal/f7/src/stm32f7xx_hal_rcc.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,12 @@ uint32_t HAL_RCC_GetSysClockFreq(void)
981981
if (__HAL_RCC_GET_PLL_OSCSOURCE() != RCC_PLLCFGR_PLLSRC_HSI)
982982
{
983983
/* HSE used as PLL clock source */
984-
pllvco = ((HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> POSITION_VAL(RCC_PLLCFGR_PLLN)));
984+
//pllvco = ((HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> POSITION_VAL(RCC_PLLCFGR_PLLN)));
985+
// dpgeorge: Adjust the way the arithmetic is done so it retains
986+
// precision for the case that pllm doesn't evenly divide HSE_VALUE.
987+
// Must be sure not to overflow, so divide by 4 first. HSE_VALUE
988+
// should be a multiple of 4 (being a multiple of 100 is enough).
989+
pllvco = ((HSE_VALUE / 4) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> POSITION_VAL(RCC_PLLCFGR_PLLN))) / pllm * 4;
985990
}
986991
else
987992
{

0 commit comments

Comments
 (0)