Skip to content

Commit e2b4822

Browse files
author
Krzysztof Blazewicz
committed
stmhal/hal/rcc: reapply HAL commit c568a2b for f4
1 parent 4f7c5fa commit e2b4822

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

stmhal/hal/f4/src/stm32f4xx_hal_rcc.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,12 @@ __weak uint32_t HAL_RCC_GetSysClockFreq(void)
893893
if(__HAL_RCC_GET_PLL_OSCSOURCE() != RCC_PLLSOURCE_HSI)
894894
{
895895
/* HSE used as PLL clock source */
896-
pllvco = ((HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> POSITION_VAL(RCC_PLLCFGR_PLLN)));
896+
//pllvco = ((HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> POSITION_VAL(RCC_PLLCFGR_PLLN)));
897+
// dpgeorge: Adjust the way the arithmetic is done so it retains
898+
// precision for the case that pllm doesn't evenly divide HSE_VALUE.
899+
// Must be sure not to overflow, so divide by 4 first. HSE_VALUE
900+
// should be a multiple of 4 (being a multiple of 100 is enough).
901+
pllvco = ((HSE_VALUE / 4) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> POSITION_VAL(RCC_PLLCFGR_PLLN))) / pllm * 4;
897902
}
898903
else
899904
{

0 commit comments

Comments
 (0)