2023-11-03 04:19 PM - edited 2023-11-03 04:37 PM
Is there a way to use timers to trigger an interrupt at between 1.00BPM and 999.00BPM, with a 2 decimal resolution? I'm currently using an STM32F373 with 8Mhz clock for my timers, and set the Timer Prescaller to 8000-1, and set the ARR register to dynamically set the BPM. The problem is I get very high resolution at lower BPM settings ( ARR = 60000 ), but not enough resolution at higher BPM ( Incrementing ARR from 100 to 101 results in BPM changing from 594.05 to 588.23. ) I would like to be able to set the timer to generate BPMs between 594 and 588 as well. Do I need to combine a second cascading timer to create an offset, or do I need to somehow change the Prescaler register as well to obtain a linear change?
Thanks!
Solved! Go to Solution.
2023-11-04 06:01 AM
Use a 32-bit timer and no (==1) prescaler. Due to only dividing 8MHz by some integer, the timer will not exactly meet the BPM wanted.
hth
KnarfB
2023-11-03 04:36 PM
TIM_OUT_FREQ = TIM_CLK / (P * Q)
Where PSC = P - 1 and ARR = Q - 1
Want more frequency options, clock faster.
2023-11-03 04:46 PM - edited 2023-11-03 05:44 PM
Update: I now see that going from 600.1BPM to 600.0BPM amounts to a 1ms change in duration per beat which would require much more frequency and is too fine-grained for my requirement, even at lower BPM. I'll need to look at setting my timer values accordingly.
2023-11-04 06:01 AM
Use a 32-bit timer and no (==1) prescaler. Due to only dividing 8MHz by some integer, the timer will not exactly meet the BPM wanted.
hth
KnarfB
2023-11-04 06:14 AM
I was using 16bits for the ARR, and now see using 32bits is what I had overlooked. Both answers together got this solved for me, thank you!!