I am trying to transmit 4 bits from a TLP-315 transmitter to a RLP-315 receiver for a project. At the receiver, I am taking the four bits and performing some comparisons on it and getting an output. I am using two PIC16F88 microcontrollers. I was wondering whether I coded the Manchester coding and used the serin, serout correct. Also, since I am using Manchester coding, do I have to send a preamble? I have attached my code below.

'Transmit
Include "Modedefs.bas"
v var word 'v is a byte to be encoded
counter var byte 'counter is a byte
encoded var word 'encoded is a word sized variable that holds the encoded byte v
'Code to be transmitted
v = 1010
'Manchester Encoding
For counter = 0 to 3 'number of bits to be encoded (4 bits)
If v.0[counter]=0 Then
encoded.0[counter*2]=0
encoded.0[counter*2+1]=1
Else
encoded.0[counter*2]=1
encoded.0[counter*2+1]=0
EndIf
Next counter
'Serial Out
serout PORTB.0, n2400, [encoded]


'Receive

'Include "Modedefs.bas"
s var word 's is a byte to be encoded
B0 var byte 'B0 is a byte
B1 var byte 'B1 is a byte
'counter var byte
encoded1 var word 'encoded1 word sized variable that holds the encoded byte v
action var byte 'action variable
alert var byte 'alert variable
B0=0 'hardwired address
B1=1 'hardwired address

'Decoding
loop:
serin PORTB.0, n2400, [encoded1]
For counter = 0 to 3
s.0[counter]=encoded1.0[counter*2]
Next counter
goto loop
End

'Tracking code
If (s.2==0) & (s.3==0) Then 'If the code matches 00 then it is in the tracking mode

If (s.0==B0) & (s.1==B1) Then 'If the address matches then
s.2=1 'Change the third bit to 1
action = s.2
alert = 0
serout PORTB.1, n2400, [s] 'Send the changed word back
Else
s.2=0 'Since the addresses does not match do not change anything
action = s.2
alert = 0
serout PORTB.1, n2400, [s] 'Send the changed word back
Endif
Endif

'Tracking and Finding code
If (s.2==0) & (s.3==1) Then 'If the code matches 01 then it is in the tracking and finding mode

If (s.0==B0) & (s.1==B1) Then 'If the address matches then
s.2=1 'Change the third bit to 1
action=s.2
alert=1
serout PORTB.1, n2400, [s] 'Send the changed word back
High 2
Else
s.2=0 'Since the address does not match do not change anything
action=s.2
alert=0
serout PORTB.1, n2400, [s] 'Send te changed word back
Endif
Endif