Benj wrote:Hi Wayne,
What I would do is on the first INT interrupt I would reset my count variable and set a timer interrupt going. On the second INT interrupt I would disable the timer interrupt.
With a normal PIC running at 19.6608MHz you can get a timer interrupt rate of 19200Hz which equates to 52us.
Ben why you don't use timer1 or timer3 as a counter? That what I would do. I the rising edge int, first read the timer, and then reset it, that way I don't need to have very high frequency timer in macro running...
Like I use in my boat CAN bus rpm measuring:
First set the timer 1 at right count speed.
Then at the rb0 int read the tmr1hi and tmr1lo at the array
Write the tmr1hi and tmr1lo at 0
Then calc the moving average at the array values
Convert those values at 16bit
Divide proper value at the calculated 16bit timer value
And VOILA I have the exact rpm value..
And the timer1 rollover int can be used at discard too long pulses..
The benefit at that type counter is that it is quite lot "lighter" to MCU to run, the interrupt frequecy is only the frequency at measured pulses, and then all I need to do is the read and reset the timer values, all other calculations can be done just when needed at main loop...
Mika