File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -917,7 +917,12 @@ uint32_t HAL_RCC_GetSysClockFreq(void)
917
917
if (__HAL_RCC_GET_PLL_OSCSOURCE () != RCC_PLLCFGR_PLLSRC_HSI )
918
918
{
919
919
/* HSE used as PLL clock source */
920
- pllvco = ((HSE_VALUE / pllm ) * ((RCC -> PLLCFGR & RCC_PLLCFGR_PLLN ) >> POSITION_VAL (RCC_PLLCFGR_PLLN )));
920
+ //pllvco = ((HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> POSITION_VAL(RCC_PLLCFGR_PLLN)));
921
+ // dpgeorge: Adjust the way the arithmetic is done so it retains
922
+ // precision for the case that pllm doesn't evenly divide HSE_VALUE.
923
+ // Must be sure not to overflow, so divide by 4 first. HSE_VALUE
924
+ // should be a multiple of 4 (being a multiple of 100 is enough).
925
+ pllvco = ((HSE_VALUE / 4 ) * ((RCC -> PLLCFGR & RCC_PLLCFGR_PLLN ) >> POSITION_VAL (RCC_PLLCFGR_PLLN ))) / pllm * 4 ;
921
926
}
922
927
else
923
928
{
You can’t perform that action at this time.
0 commit comments