SERIN2 – SEROUT2 and Manchester mistake.
	
	
		Hello, i'm trying to send some datas over wireless network from a pic to another one.
For the explanation, pic sender is PICTX and the other is PICRX.
My pics are 12F683 both.
The code sent by the PICTX seems to be okay
Example : If PICTX send the letter " d " in Manchester style over the 433Mhz network, i can read 01 10 10 01 01 10 01 01 on the input pin of PICRX.
Okay but not perfect because i haven't work enough to send the WakeUp string in Manchester style….
This is the code i use for the PICTX :
'---------- Begining
@ device PIC12F683, intrc_osc_noclkout, wdt_off, pwrt_on, mclr_off, protect_off, bod_on 
OSCCON = %01110000
DEFINE OSC 8
ansel  = 0
cmcon0 = 7
trisio = %000011 
INCLUDE "modedefs.bas"
SYMBOL TRANSMISSION  = GPIO.2
DEFINE CHAR_PACING 100
LOW TRANSMISSION
Clear 
Pause 200
'---------- End of header and now here are the variables
CounterA        var Byte
MyDataIn        var Byte
ManchesterWord  var Word[6]
'---------- End of variables and now, here is the heart
MyDataIn = "d"
 GOSUB EncodeManchester
 serout2 TRANSMISSION, 16468, [$55,$55,$55,$aa,IBIN16 Manchesterword,13,10]
 END
'----------Manchester Encoding
EncodeManchester:
ManchesterWord=0
For CounterA=0 to 7
If MyDataIn.0=0 then
ManchesterWord.14=1
else
ManchesterWord.15=1
endif
If CounterA<7 then ManchesterWord=ManchesterWord>>2
MyDataIn=MyDataIn>>1
Next CounterA
Return
'EOF
'-------------
Well, now, let's talk about my PICRX.
I did a mistake into my code but i don't find wich...
I'm not able to decode my manchester words.
This is the code i use for PICRX:
@ device PIC12F683, intrc_osc_noclkout, wdt_off, pwrt_off, mclr_off, protect_off, bod_on 
'----
OSCCON = %01110000
DEFINE OSC 8
ansel  = 0
cmcon0 = 7
'----
trisio = %001000 ' Input pin is  GPIO 3
INCLUDE "modedefs.bas"
LED             VAR GPIO.0
RECEPTION       VAR GPIO.3
INFO            VAR GPIO.2
CounterA        var Byte
ErrorFlag       var Bit
WakeUp          var Byte
MyDataOut       var Byte
ManchesterWord  var WORD[6] 
Clear 
Low LED
LOW INFO
FLAG = 1
Pause 1000
'----
Wait55:  
SERIN RECEPTION, n9600, WakeUp
If WakeUp = $55 Then
    SERIN RECEPTION, n9600, WakeUp 
    If WakeUp = $55 Then
        SERIN RECEPTION, n9600, WakeUp 
        If WakeUp = $55 Then  
            SERIN RECEPTION, n9600, WakeUp 
            If WakeUp = $aa Then 
                goto Receive              
            ENDIF                         
        ENDIF    
    endif
endif
Goto Wait55
END
'----------
Receive: 
SERIN2 RECEPTION, 16468, [ManchesterWord] ' MY ERROR IS HERE I THINK!!
serout2 INFO, 16468, ["This is ManchesterWord : ",IBIN16 ManchesterWord,13,10]
GOSUB DecodeManchester
    IF ERRORFLAG THEN
        serout INFO, N9600, ["Error !",13,10]
        Pause 300
        goto Wait55
    ENDIF
serout INFO, N9600, ["Value is Okay. (",MyDataOut,")",13,10]
GOSUB Action
GOTO Wait55
'----------
Action :
If (MyDataOut = "c") Then     
High LED
Pause 1000
Low Led
Endif
Return
'----------
DecodeManchester:
ErrorFlag=0
For CounterA=0 to 7
If ManchesterWord.1=0 then
MyDataOut.7=0
If ManchesterWord.0=0 then ErrorFlag=1
else
MyDataOut.7=1
If ManchesterWord.0=1 then ErrorFlag=1
endif
ManchesterWord=ManchesterWord>>2
If CounterA<7 then MyDataOut=MyDataOut>>1
Next CounterA
Return
'EOF
'-----------------------
I’m sure it’s a stupid error but i’ve tried many things and i didn’t found.
Any help ?
Thanx a lot.
Lyd.