getting info here is a bit like pulling teeth , but lets assume a 48mhz clock and that timer4 is free along with a pin like portb .2
Code:
some vars
bit_is var byte
I_data var PORTB.2 'lets call this the input
a routine
bit_test:
bit_is =0
t4con=0 ' timer off
tmr4=0 ' clear timer
pir3.3=0 'clear timer overflow flag
while ( ! i_data) : wend 'wait here till input goes high to sync up
while ( i_data) : wend ' wait here till input goes low
t4con=6 ; prescale 16 timer on
while ( ! i_data) : wend ' wait here till input goes high
if pir3.3 then bit_is=1 ; offtime > 340 uS
else
bit_is=0 ' the offtime < 340 uS
endif
return
it could be nicer if
1 does the line idle high or low
2 what does a start bit look like
3 how many bits in a session
4 100uS / Off - 400uS a 1 or a 0 ?
Bookmarks