A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
|
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 |