Hi guys,
I'm trying to send/receive data between 2 PICs on the same circuit.
The first one (16F1508) is sending data with debug command.
Code:
INCLUDE "modedefs.bas"
DEFINE DEBUG_REG PORTA ' Set Debug pin port
DEFINE DEBUG_BIT 2 ' Set Debug pin bit
DEFINE DEBUG_BAUD 2400 ' Set Debug baud rate
DEFINE DEBUG_MODE 0 ' Set Debug mode: 0 = true, 1 = inverted
PreAmble CON $A5
debug PreAmble,$af,$c2,$b5,$ef,13,10
The second one (16F1503) is receiving the data with debugin command.
Code:
INCLUDE "modedefs.bas"
DEFINE DEBUG_REG PORTC ' Set Debug pin port
DEFINE DEBUG_BIT 2 ' Set Debug pin bit
DEFINE DEBUG_BAUD 2400 ' Set Debug baud rate
DEFINE DEBUG_MODE 0 ' Set Debug mode: 0 = true, 1 = inverted
DEFINE DEBUGIN_REG PORTA ' Set Debugin pin port
DEFINE DEBUGIN_BIT 1 ' Set Debugin pin bit
DEFINE DEBUGIN_BAUD 2400 ' Set Debugin baud rate (same as Debug baud)
DEFINE DEBUGIN_MODE 0 ' Set Debugin mode: 0 = true, 1 = inverted
Main:
DEBUGIN 1000,timeoutlabel,[WAIT("$af"),DAT1,DAT2,DAT3]
pause 3000
IF DAT1=$c2 THEN
GOTO SELECTION
ENDIF
goto main
timeoutlabel:
debug DEC 99,DAT1,DAT2,DAT3,13,10
pause 3000
goto main
The data validation fails and the code jumps to the timeout label.
The timeout label is sending the received information out for troubleshooting purposes.
For troubleshooting I'm using a Microchip Pickit serial analyzer.
The information sent is different from the information received.
This is the data sent from PIC #1 and captured with the analyzer:
Code:
[00][A5][AF][C2][B5][EF][0D][0A]
And this is the data sent from PIC #2 (when in timeoutlabel) and captured with the analyzer:
Code:
[4E][4E][BF][79][0D][0A][00]
Why is the data different? The only data that seems to be correct are the carriage return bytes.
What am I doing wrong?
Thanks
Bookmarks