Skip to main content
Ezgi
Associate III
Feb 7, 2024 6:10 AM UTC
Question

setting source of SYSCLK to PLLCLK affects the behaviour of TIM2

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.

This topic has been closed for replies.

3 replies

Associate
Feb 7, 2024 7:01 AM UTC

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

 

ST Employee
Feb 7, 2024 9:31 AM UTC

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
Super User
Feb 7, 2024 10:03 AM UTC

@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.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.