Lets look at this and see what its doing:
Code:
INTCON = 0 ' Interrupts off
CCP1CON = %00000101 ' Capture mode, capture on rising edge
T1CON = 0 ' TMR1 prescale=4, clock=Fosc/4, TMR1=off
T1CON.4 = 0
T1CON.5 = 1
CLEAR
Reload:
TMR1H = 0 ' Clear high byte of TMR1 counter
TMR1L = 0 ' Clear low byte
T1CON.0 = 1 ' Turn TMR1 on here 'here you turn on the timer, but at what state is your signal?
Next you wait for capture flag, but again, if the flag sets on rising edge (or falling) but
you started in the middle of a "high", you will stop when 75% of the cycle is done.
Capture = 0 ' Clear capture int flag bit
While !Capture ' Wait here until capture on rising edge
Wend
T1CON.0 = 0 ' Turn TMR1 off here
' Rising edge detected / stuff 'captured' Timer1 value in T1
T1.HighByte = CCPR1H ' I don't understand why you replace T1 count with CCPR1
T1.LowByte = CCPR1L 'T1 has the counts you are comparing in your spreadsheet
DEBUG #T1,13,10
GOTO ReLoad
You need to wait for a rasing edge before you start the counter, then on next rising edge, stop and get the counts. Or even better, set a word = to count, after you turn the timer off. then reset it and turn it back on. Right now you don't turn it back on until after you have sent data out. You are missing a portion of your signal this way.
HTH
Bookmarks