Hi Leigh,
Just took a quick look at your program, and I can't answer all those questions, but did notice one thing.
The capture function of the CCP simply latches the Timer value into the CCPRH:L register when the specified event occurs. In this case thats after 4 RISING edges. To get a meaningfull result, the timer has to be started at the same time as the CCP starts counting it's 4 periods.
You can just leave the timer turned off and let it capture 0 the first time, then as soon as the CCP1IF (PIR1.2) is raised, imediately start the timer, then reset the CCP1IF. On the next capture you should have a valid result.
I don't know about all the rest, but one thing at a time usually works best.
Maybe something like this
Code:
CCP1CON = %00000110 ' Enable the CCP1 capture, every 4th rising edge
loop:
T1CON = %00010000 ' TMR1 prescale=1:2 Timer OFF
TMR1H = 0 ' Zero the Timer
TMR1L = 0
capture = 0
StartLoop:
IF (capture = 0) Then StartLoop ' Wait here for the first capture
T1CON.0 = 1 ' Start the Timer
capture = 0 ' Reset the capture flag
CaptureLoop:
IF (capture = 0) Then CaptureLoop ' Wait here until captured
period.lowbyte = CCPR1L ' Store the captured value in
period.highbyte = CCPR1H ' period variable
DT
Bookmarks