2022-05-01 07:52 AM
I need to trigger a timer updateEvent at a rate ranging from 2 BeatsPerMinute to 1000 BeatsPerMinute. I can get the correct range by setting the timer's prescale value from 1 to 30,000 but I need to land on precise BeatsPerMinute integers. If I set the prescale to 1000, I get 76.9054 BeatsPerMinute but would like updateEvent interrupts exactly 76BPM.
Do I hook into the RTC so that I am using a 32.768KHz clock source to make the timing work as I require?
2022-05-01 08:13 AM
What part are we talking about, and what frequency are you clocking it at?
The TIM can have awkward factors, and the prescale/period are coded as N-1
Divide by 1000 would be 999, as this is a comparator for a 0 .. 999 range, to match the last count prior to the update
2022-05-01 08:29 AM
Integer values of 2-1000Hz should be possible to hit exactly with typical clock frequencies.
> If I set the prescale to 1000, I get 76.9054 BeatsPerMinute
How exactly are you calculating this? What is your timer tick frequency?
2022-05-01 09:16 AM
Thank you for pointing this out. I now see that I can get integer values using the 84MHz osc by changing the prescale value.
2022-05-01 11:19 AM
> Integer values of 2-1000Hz should be possible to hit exactly with typical clock frequencies.
Show.
Btw., 2-1000BPM is 33.333mHz-16.667Hz... ;)
JW
2022-05-01 12:31 PM
My clock is 84MHz. What prescale value can I use to get 9kHz? Also, what prescale would get me to 11kHz? I'm able to get precise integers on the other.
2022-05-01 07:22 PM
How about RTC with 32868 Hz precise LSE crystal?
2022-05-01 07:29 PM
I'm currently looking into using a freeRTOS Task with timestamps between 'beats' instead of a hardware timer. Not sure if this is a good approach but will test it.