Hi People,
i have a question ,can I use this manchester code like in this example.
Trough PortA.0 is incoming encoded data from my transmitter and is then decoded and trough PortA.1 is going encoded data out.
Define LOADER_USED 1
Include "modedefs.bas" ' Mode definitions for Serout
ADCON1=7
define osc 4
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_SPBRG 207 ' 1200 Bauds
DEFINE HSER_CLOERR 1
n var byte
d var byte
myVar VAR byte
CounterA var Byte
ErrorFlag var Bit
MyData var Byte
encoded var Word
v var word
pause 10 ' safe start-up delay
Main:
serin porta.0,N1200,v
ErrorFlag=0
For CounterA=0 to 7
If v.1=0 then
MyData.7=0
If v.0=0 then ErrorFlag=1
else
MyData.7=1
If v.0=1 then ErrorFlag=1
endif
v=v>>2
If CounterA<7 then MyData=MyData>1
next
goto encodemanchester
encodeManchester:
For d=0 TO 7
IF mydata.0[d]=0 Then
encoded.0[d*2]=0
encoded.0[d*2+1]=1
Else
encoded.0[d*2]=1
encoded.0[d*2+1]=0
EndIF
serout porta.1,N1200,[encoded]
hserout [encoded]
Next
goto main
end
Please for help,thanks very much.
Pesti.
Bookmarks