Good day Picers.
I am sending serial data from one pic to another using two 433Mhz RF Modules.
On the receiver side, I send some data (for debug purposes) to my PC.
My Transmitter Code:
<hr>
<code>
'************************************************* ***************
'* Name : Transmit.bas *
'************************************************* ***************
Include "modedefs.bas"
DEFINE OSC 4 ' Set the Xtal frequency
SerialOutPin VAR PORTC.2 ' Serial Out
LEDPin Var PORTC.3
DEFINE CHAR_PACING 1000
ADCON1 = 7
TRISC = %00000000 ' SET ALL PORT C TO OUTPUTS
Main:
PAUSE 5000
serout2 SerialOutPin, 16780, [#1,#2,#3,#4,#5]
Pause 1000
HIGH LEDPin
Pause 1000
LOW LEDPin
PAUSE 1000
Goto Main
END
</code>
<hr>
My Receiver Code :
<hr>
<code>
'************************************************* ***************
'* Name : Receiver.bas *
'************************************************* ***************
Include "modedefs.bas"
DEFINE OSC 4 ' Set the Xtal frequency
SerialInPin VAR PORTC.2 ' Serial Out
SerialOutPin VAR PORTB.7
LEDPin Var PORTC.3
CDPin VAR PORTD.2
CDPinState VAR Byte
DataReceived var byte[5]
I VAR BYTE
iLoopPin var byte
Data_ArrayCount var byte
ADCON1 = 7
Main:
Pause 5000
high LEDPin
Loop:
for Data_ArrayCount = 0 to 4
DataReceived[Data_ArrayCount] = 0
next Data_ArrayCount
SERIN2 SerialInPin,396, 4000, SerialTimeout, [str DataReceived\5]
if (DataReceived[0] = 1 and DataReceived[1] = 2 and DataReceived[2] = 3) then
serout2 SerialOutPin, 16780, ["DATA=======", 13, 10]
else
serout2 SerialOutPin, 16780, ["JUNK:", #DataReceived[0], ":", #DataReceived[1], ":", #DataReceived[2],13,10]
endif
Goto LOOP
SerialTimeout:
serout2 SerialOutPin, 16780, ["TIMEOUT", 13, 10]
Goto LOOP
END
</code>
<hr>
On the PC Side I get the following:
<hr>
JUNK:103:216:131
TIMEOUT
JUNK:103:216:131
TIMEOUT
JUNK:103:216:131
TIMEOUT
JUNK:103:216:131
TIMEOUT
JUNK:103:216:131
<hr>
Any idea what I'm doing wrong?
Bookmarks