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_Transmitter
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' RF byte transmitter, checks RA0 - RA3 and RB4 - RB7 for input. '
' Sets coresponding input into an array '
' array is sendt serially to another PIC, which decodes bits. '
' Eirik Taylor '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
dim sendbit as byte[8]
dim i as byte
main:
TRISB = 110000 ' pins RB0 - RB3 as outputs, RB4 - RB7 as inputs
PORTB = 0
ANSEL = 0
ADCON0 = 0
TRISA.0 = 1
TRISA.1 = 1
TRISA.2 = 1
TRISA.3 = 1
gather_input:
' get input from RA0 - RA3 and RB4 - RB7 and put into byte array "sendbit"
' set bits according to input, porta
i = 0
for i = 0 to 3
sendbit[i] = Testbit(porta, i)
next i
' set bits according to input, portb
i = 0
for i = 0 to 3
sendbit[i+4] = Testbit(portb, (i+4))
next i
' result is 8 bit long byte with 1s and 0s symbolizing on or off.
output:
' transform sendbyte into serial data stream
' start bit to intiate transmission
Setbit(portb,0)
delay_us(600)
Clearbit(portb,0)
delay_us(300)
' convert sendbit into output pulse string
i = 0
for i = 0 to 7
Setbit(portb,0)
if (sendbit[i] = 1) then
delay_us(600) ' 450µs represents a 1
else
delay_us(300) ' 300µs a 0
end if
Clearbit(portb,0)
delay_us(400) ' 300µs between every bit
next i
goto gather_input
end.
Revise this Paste
Parent: 28299
Children: 28301