Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as C by Sff ( 13 years ago )
program RF_Receiver
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Serial byte reciever, checks RA0 for input. '
' Sets coresponding input into an array '
' array is decoded into corresponding output patteren. '
' Eirik Taylor '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dim sendbit as byte[8]
dim i, cnt as byte
main:
ANSEL = 0
ADCON0 = 0
TRISA = 1 ' pin 17 (RA0) as input
TRISB = 0
cnt = 0
sendbit[0] = 0
sendbit[1] = 0
sendbit[2] = 0
sendbit[3] = 0
sendbit[4] = 0
sendbit[5] = 0
sendbit[6] = 0
sendbit[7] = 0
' Initiate portb
portb = 255
delay_ms(10)
portb = 0
delay_ms(10)
gatherinput:
' look for possible startbit
do
loop until porta.0 = 1
cnt = 0
while porta.0 = 1 ' timer
delay_us(20) ' effective delay works out to 27 µs
Inc(cnt)
wend
if (cnt < 26) and (cnt > 18) then ' startbit length around 22 cnts
goto writesendbit
else
goto gatherinput
end if
writesendbit:
' save data stream into sendbit array
i = 0
for i = 0 to 7 ' timer
do
loop until porta.0 = 1
cnt = 0
while porta.0 = 1
delay_us(20) ' effective delay works out to 27 µs
Inc(cnt)
wend
if (cnt <= 30) and (cnt > 20) then ' Logic 1 around 17 cnts
sendbit[i] = 1
end if
if (cnt <= 20) and (cnt >= 9) then ' Logic 0 around 11 cnts
sendbit[i] = 0
end if
next i
output:
' convert sendbit into output
i = 0
for i = 0 to 7
if sendbit[i] = 1 then
Setbit(portb, i)
else
ClearBit(portb, i)
end if
next i
goto gatherinput
end.
Revise this Paste
Parent: 28300
Children: 72537