Here's another approach.
You can use timer 1 as a frequency counter. Not sure if will be accurate enough? You did not say which pic you are using? Timer 1 external input is normally on portc. There should be a way to route the comparator output to tmr1? You will have to play with the pause statement to calibrate the output ie "pause 97" to compensate for the delays in pbp.
CCP1CON = %00000101 ' Capture every rising edge
T1CON = %00000011 ' No prescale/Osc off/Sync on/External source/TMR1 on
Freq var word ' 100ms count result
LOOP:
TMR1H = 0 ' Clear Timer1 high 8-bits
TMR1L = 0 ' Clear Timer1 low 8-bits
T1CON.0 = 1 ' Start 16-bit timer
Pause 100 ' Capture 100 mS of Input
T1CON.0 = 0 ' Stop 16-bit Timer
Freq.BYTE0 = TMR1L ' Read Low 8-bits
Freq.BYTE1 = TMR1H ' Read High 8-bits
GoTo LOOP




Bookmarks