cancel
Showing results for 
Search instead for 
Did you mean: 

APB1 TIM2 clock frequency

Skyy_Tsuki
Associate II

I want to use tim 2 at the frequency of APB1 and not to the sysclock how i can do that, can somoene explain me or look at my code at the bottom to help me i want to use the 0.09375 frequency for my projet. thanks 

Capture d’écran 2024-02-13 102336.png

1 ACCEPTED SOLUTION

Accepted Solutions
GwenoleB
ST Employee

Hello @Skyy_Tsuki ,

The following statement is mentioned in RM0008, section RCC:

The timer clock frequencies are automatically fixed by hardware. There are two cases:
1. if the APB prescaler is 1, the timer clock frequencies are set to the same frequency as
that of the APB domain to which the timers are connected.
2. otherwise, they are set to twice (×2) the frequency of the APB domain to which the
timers are connected.

Currently, your APB prescaler is set to 2, therefore the second point is applied. 

I could recommend you to divide by 2 the input clock frequency of timer by setting Internal Clock Division (CKD) parameter in CubeMX.

 

Kind Regards,

Gwénolé

View solution in original post

3 REPLIES 3
GwenoleB
ST Employee

Hello @Skyy_Tsuki ,

The following statement is mentioned in RM0008, section RCC:

The timer clock frequencies are automatically fixed by hardware. There are two cases:
1. if the APB prescaler is 1, the timer clock frequencies are set to the same frequency as
that of the APB domain to which the timers are connected.
2. otherwise, they are set to twice (×2) the frequency of the APB domain to which the
timers are connected.

Currently, your APB prescaler is set to 2, therefore the second point is applied. 

I could recommend you to divide by 2 the input clock frequency of timer by setting Internal Clock Division (CKD) parameter in CubeMX.

 

Kind Regards,

Gwénolé

Where i can divide on cube mx i don't see CKD in cubeMX and i have a question i have a period of 400ms for one period and the timer go crazy everytime i have one interrupt on my pin the timer show me 7048 or 128 or 3128 etc... i don't have never ever a constant value for my timer and my input signal is very slow i have the possibility to count the numbre of pulse during my two interrupts can you help me please.

If you want the timer to run slower, just use its own prescaler TIMx_PSC.

JW