If you search the forums you'll find code from Bruce Reynolds that uses the Capture/Compare register to measure the period between adjacent rising edges (i.e. one cycle and independent of the duty cycle).
The code you posted is C while this forum is dedicated to PicBasic and PicBasiPro. If your class works in C, then you should be asking this in some forum dealing with using C to program PICs.
Here's a link to Bruce's code to capture a pulse (not one complete cycle) which is closest to your example. It is well commented.




Bookmarks