cancel
Showing results for 
Search instead for 
Did you mean: 

Could anyone help me calculate TIM frequency?

Jvan .10
Associate III

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!

1 ACCEPTED SOLUTION

Accepted Solutions

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
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3
KnarfB
Principal III

> 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?

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
Up vote any posts that you find helpful, it shows what's working..
Jvan .10
Associate III

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