Skip to main content
Jvan .10
Associate III
March 10, 2021
Solved

Could anyone help me calculate TIM frequency?

  • March 10, 2021
  • 3 replies
  • 1141 views

Hello everyone,

I'm using TIM3 on my Nucleo H745. If it's correct this TIM gets fed from the CPU clock, so it runs at 480MHz. That's what I thought at least.

Using these settings;

htim3.Init.Prescaler = 48000;

htim3.Init.Period = 10000;

To my calculations this should be equal to 1 second.

480.000.000 / 48.000 = 10.000 Hz

When setting the period to 10000, this means it should overflow every second, right?

Not in my case. When hooking up 2 LEDs and setting their intervals to 20000 and 40000 you would expect LED1 to blink 2x in the time LED2 blinks 1x.

They blink at almost the same rate, LED2 is just a little bit slower, which means my calculations are wrong.

Can anyone spot the mistake?

Thanks!

This topic has been closed for replies.
Best answer by Tesla DeLorean

Values need to be N-1 form, ie 48000-1 and 10000-1 to divide by 480,000,000

3 replies

KnarfB
Super User
March 10, 2021

> When hooking up 2 LEDs and setting their intervals to 20000 and 40000

Can you explain what you exactly did? If you set timer period to 10000 it will count in interval 0-9999. Where did you set 20000, 40000?

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
March 10, 2021

Values need to be N-1 form, ie 48000-1 and 10000-1 to divide by 480,000,000

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Jvan .10
Jvan .10Author
Associate III
March 11, 2021

Thank you both, together you fixed my issue. I was wrong in my calculations from MHz to Hz