OK, first things first I'm new to programming PIC's (although have been prgramming PC's etc for over 10 years now) and this is my first time out with PBP.
For reference I am using a 16F877 MCU running with a 4Mhz crystal and porting my information out via serial as I don't have an LCD or similar at present.

I've been trying for the past day or so to make a basic readout of
RPM based on an incoming square wave to pin B0.
I've got a 4500rpm signal coming in based on my cars crank angle sensor readout (4 pulses per rotation) and using the count function I can relate that back no problem (300 rps/4 * 60=4500rpm).
What I need to do though is count the pulses WITHOUT holding the MCU in a state of flux while the reading is being taken.
I've tried doing this with the pulsin command but I'm not sure I'm getting the right things back from it.
The pulse (in theory) should run high for 1/8 of a revolution and low for 1/8 of a revolution which signifies a quarter turn on the crank.
Currently if I count the pulse width using the pulsin command I get a result of 165 high and 168 low (using two pulsin commands, one for high one for low).

The area where I am getting stuck is how to convert this into a useable RPS value and therefore convert to RPM.

This has to be done fairly rapidly as the circuit I am designing will use this value to retard the timing on my car based on RPM and Airflow (Airflow is an easy 0-5v reference and can be read via an A/D input so no problems there). Obviously there will only be around 12-14 revs per second at idle raising to 125 at the engines redline of 7500RPM so it has to fit with a sample time of around 250ms I think (correct me if I'm wrong though!).

Can anyone offer any suggestions or code snippets for how I should go about the calculation - or even if there is a much simpler/more efficient wat of doing it.

One possibility I did think of is measuring the time between the pulses leading edges so I could get a time between the first pulse and the next and base the rps on that after multiplying by 4.

Thanks in advance.

Leigh Windridge