Hi,

You were near it in your question ...

rmp=60/period * 1 000 000

But ...

care to the units of "period" , and overflow issues ...

if you Xtal is 4 Mhz, then, period will be in µS ... the minimum "correct" display will be ~ 1100 rpm due to an overflow of your timer ... ( Period > 65535 ...)

Then, the simplest way is to use a prescaler value of 8 ( 137 rpm ) or, if possible, 16 ( 68 rpm minimum )

period will be in 8µS ( or 16 µS ) steps

so,your result will then be :

rpm = 60*1 000 000 /period*prescaler_value

due to PBP limitations you'll have to use the DIV32 "function"

So it will be Written :


intermediate = 60 * 1000 / prescaler_value ' Compulsory !!!
' ( no "intermediate CON xxx" allowed )

' Disable interrupts ... if some used !!!

Dummyvar = 1000 * intermediate

rpm = DIV32 period

' re-enable interrupts allowed

Alain



Alain