capture
ansel0=%00000000 'all digital
trisa=%11111111 'set all port a pins to input cap1,cap2,cap3
trisb=%00000000 'set all port b pins as output
t1 var word
t2 var word
t3 var word
Capture1 var pir3.1 ' tmr5 value was capture by the active edga on capl input
Capture2 var pir3.2 'interrupt flag for pin cap2
Capture3 var pir3.3 'interrupt flag for pin cap3
' auto time base reset, capture on rising to falling edge
RiseToFall CON %01000111
' auto time base reset, capture on falling to rising edge
FallToRise CON %01000110
false con 0
true con 1
'capture mode
intcon =0 'interrupts off
tmr5h = 0 'clean high byte of tm5 counter
tmr5l = 0 'clean low byte
t5con = %00000001 ' prescale 1:1, int clock, tmr5 =on
cap1con=%01000111 ' enable caputure,pulse width measurement mode,
'every rising o falling edge
cap2con=%01000101
cap3con=%01000101
Capture1 = false 'rest caputer flag
Capture2 = false
Capture3 = false
main :
if (Capture1=true)and(capture2=true)and(capture3 = true) then
high portb.7
endif
end
if (Capture1=true)and(capture2=false)and(capture3 = true) then
high portb.6
endif
goto main




Bookmarks