I am writing code for an STM32L433RC MCU that returns the tick period of a timer (TIM1, TIM2, TIM6, etc.) using the LL driver but I can't figure out how to calculate the timer clock frequency programmatically. The documentation clearly shows that the timers are clocked by a multiple of PCLK1 or PCLK2 depending on which timer is being used. The part I can't work out is how do I know what the multiplier is? If I know the multiplier then I can calculate the timer clock frequency easily. I read a blog saying it is automatically set in hardware when the APB1/2 pre-scalers are set, however it did not go into further details. I cant find anything in any of the datasheets or manuals I have read except for the diagram that shows the multiplier as either x1 or x2 (see the image I have attached). Does anybody have any insight into this?
It automatically changes when you change the APBx prescaler. If the respective APB prescaler is >1 (2, 4, 8 or 16) then it is x2 otherwise it is x1.
You can see this from the CubeMX configuration tool. I'm sure it's somewhere in the documentation. Since the maximum frequency of the APBx is 80MHz this enforces a maximum frequency of 80MHz for the timer clocks.