Skip to main content
Ezgi
Associate III
February 7, 2024
Question

setting source of SYSCLK to PLLCLK affects the behaviour of TIM2

  • February 7, 2024
  • 3 replies
  • 1189 views

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

Associate
February 7, 2024

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
February 7, 2024

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
February 7, 2024

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