cancel
Showing results for 
Search instead for 
Did you mean: 

setting source of SYSCLK to PLLCLK affects the behaviour of TIM2

Ezgi
Senior

Hi,

When I set the clock source of SYSCLK to HSI, I can get the 1 ms timer from TIM2. However, when I set the source of SYSCLK to PLLCLK, I can't get 1 ms timer from TIM2. Why? (The MCU is STM32F407VETx)

 

I would appreciate any help.

 

*Edit : The problem was solved.

3 REPLIES 3
Elatewendy
Associate III

Hi,

What's the value of Prescaler and Counter Period?

You can calculate the timing time using the following formula:

fclk/(pre+1)/(counter+1)

 

You can get the clock of TIM2 through the Clock Configuration of CUBEMX.This is the simplest method。

For example:

Elatewendy_0-1707289156023.png

 

Sarra.S
ST Employee

Hello @Ezgi

This is due to the different clock configurations when changing the SYSCLK source from HSI to PLLCLK.

TIM2 is clocked from the APB1 clock, and when you switch the SYSCLK source to PLLCLK, the APB1 clock frequency is different ( you can see that using CubeMX as suggested by @Elatewendy

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Andrew Neil
Evangelist III

@Ezgi wrote:

*Edit : The problem was solved.


Please mark the solution - so that everyone can see both that it is solved, and what the solution was.