cancel
Showing results for 
Search instead for 
Did you mean: 

Generating Timer Interrupt between 1BPM to 999BPM

LMorr.3
Senior II

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!

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

4 REPLIES 4

TIM_OUT_FREQ = TIM_CLK / (P * Q)

Where PSC = P - 1 and ARR = Q - 1

Want more frequency options, clock faster.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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.

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

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