STMicroelectronics / stm32l0xx_hal_driver

Provides the STM32Cube MCU Component "hal_driver" of the STM32L0 series.
BSD 3-Clause "New" or "Revised" License
8 stars 2 forks source link

HAL_RCC_GetSysClockFreq() uses 64 bit arithmetic when 32 would suffice #12

Open kasjer opened 2 weeks ago

kasjer commented 2 weeks ago

Function HAL_RCC_GetSysClockFreq() casts numbers to uint64_t when calculating pllvco. This is far beyond what is needed and results in inclusion of additional code from gcc library and in turn increases code size. In my case code size was increased for over 700 bytes for no reason.

Describe the set-up

Additional context Problematic lines: https://github.com/STMicroelectronics/stm32l0xx_hal_driver/blob/86984275fa7dbaa617713d0309575fc2c2fa1448/Src/stm32l0xx_hal_rcc.c#L1245 https://github.com/STMicroelectronics/stm32l0xx_hal_driver/blob/86984275fa7dbaa617713d0309575fc2c2fa1448/Src/stm32l0xx_hal_rcc.c#L1251 https://github.com/STMicroelectronics/stm32l0xx_hal_driver/blob/86984275fa7dbaa617713d0309575fc2c2fa1448/Src/stm32l0xx_hal_rcc.c#L1255

Removing casts reduces code size without any additional penalty.

TOUNSTM commented 2 weeks ago

ST Internal Reference: 184777