PIC 18F458 Timing

Started by July 14, 2004
I'm using an accelerometer to measure velocity. So it's VERY
important that I know the time between each measurement of the
accelerometer. I have a 4MHz clock and I'm using CCS C compiler and
my code is as follows:

while( input(PIN_C2) ); // wait until low
while( !input(PIN_C2) ); // wait until high
while( input(PIN_C2) ) { // count high-time
high++;
}
while( !input(PIN_C2) ) { // count low-time
low++;
}

value = (float)high/(high + low); // calculate
value
Thanks,
Shamoon