cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_RCC_GetSysClockFreq(void) wastes code space with unnecessary (unt64_t) divide.

EdGi
Associate III

HAL_RCC_GetSysClockFreq(void) in stm32f7xx_hal_rcc.c uses a (unt64_t) divide which could be avoided. This uses, on my build, 716 bytes of code space alone for the required _udivmoddi4 call, and this is not used anywhere else in my code.

Would it be possible to investigate recreating the calculation more efficiently?

There is already some bit manipulation in the calculation, and it would appear that the 64-bit datatype is just not required for the significant bits involved.

11 REPLIES 11

Isn't it easier to maintain the "last system frequency I switched to" in a variable?

JW

> their goal is code which works in every case

But in reality their implementation is so terrible that it doesn't work in any case, even the USART...