Hi Koossa,
Background Question:
How much distance between master and slave? I am thinking maybe baud rate is too high due to line capacitance, I just had that problem with an ethernet connection, couldn't use 100 had to tell computer to use 10mbs.
Hi Koossa,
Background Question:
How much distance between master and slave? I am thinking maybe baud rate is too high due to line capacitance, I just had that problem with an ethernet connection, couldn't use 100 had to tell computer to use 10mbs.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Joe, the distance between my Master and slave is only about 1.5 meters.
<hr>
Darrel
When I remove the handshacking it is working!!
<b>
WAITING FOR REPLY..
REC:1
WAITING FOR REPLY..
REC:1
WAITING FOR REPLY..
REC:1
WAITING FOR REPLY..
REC:1
WAITING FOR REPLY..
REC:1
WAITING FOR REPLY..
REC:1
WAITING FOR REPLY..
REC:1
</b>
Do I need to play arround with "pause"?
See Posts #2 & #5.
Failing that, post the program as it sits now...
Skimask
Thank you for your reply!
Whith the following code I only get..
<b>
WAITING FOR REPLY..
WAITING FOR REPLY..
WAITING FOR REPLY..
WAITING FOR REPLY..
WAITING FOR REPLY..
WAITING FOR REPLY..
WAITING FOR REPLY..
WAITING FOR REPLY..
WAITING FOR REPLY..
WAITING FOR REPLY..
WAITING FOR REPLY..
WAITING FOR REPLY..
WAITING FOR REPLY..
WAITING FOR REPLY..
WAITING FOR REPLY..
</b>
SLAVE
<hr>
<CODE>
Include "Modedefs.bas"
DEFINE OSC 4
DE_OR_RE VAR PORTC.5 ' DE and RE Pin of SN75176
LEDPIN VAR PORTD.2 ' LED to confirm PIC is running
DATARECEIVED VAR BYTE
'======== HSEROUT, HSERIN SETTINGS ==========
DEFINE HSER_RCSTA 90h
define HSER_TXSTA 24h
define HSER_SPBRG 103
DEFINE HSER_CLROERR 1
RCIF VAR PIR1.5
TXIF VAR PIR1.4
ADCON1 = 7
TRISC = %10000000
pause 200
HIGH LEDPIN
Main:
LOW DE_OR_RE ' Make ready for RX
PAUSE 4
hserin 100,Main,[WAIT ("S"),DATARECEIVED] ' Looking for "S0"
IF DATARECEIVED = "0" THEN
HIGH DE_OR_RE ' Make ready for RX
PAUSE 4
HSEROUT ["R1"] ' Send R1
ENDIF
GOTO MAIN
END
</CODE>
<hr>
MASTER
<hr>
<CODE>
Include "Modedefs.bas"
DEFINE OSC 4
DE_OR_RE VAR PORTC.5 ' DE and RE Pin of SN75176
RS232_DEBUG_PIN VAR PORTB.5 ' Debugging to PC
LEDPIN VAR PORTD.2 ' LED to confirm PIC is running
DATARECEIVED VAR BYTE
'======== HSEROUT, HSERIN SETTINGS ==========
DEFINE HSER_RCSTA 90h
define HSER_TXSTA 24h
define HSER_SPBRG 103
DEFINE HSER_CLROERR 1
RCIF VAR PIR1.5
TXIF VAR PIR1.4
ADCON1 = 7
TRISC = %10000000
PAUSE 200
HIGH LEDPIN
Main:
HIGH DE_OR_RE ' Make ready for TX
PAUSE 4
HSEROUT ["S0"]   ; ' Send "S0"
LOW DE_OR_RE ' Make ready for RX
PAUSE 4
SEROUT RS232_DEBUG_PIN,N2400,["WAITING FOR REPLY..", 13, 10] ' DEBUG TO PC
hserin 100,Main,[WAIT ("R"),DATARECEIVED]
SEROUT RS232_DEBUG_PIN,N2400,["REC:",DATARECEIVED, 13, 10] ' DEBUG TO PC
GOTO Main
END
</CODE>
<hr>
Any idea what I am doing wrong?
Thank you very much!!!!
Koossa
It takes at least 87.5ms for each of those SEROUT debug statements to execute at 2400 baud. My guess is that both sides are getting sync'd up into not receiving each others inputs and they both end up missing each others outputs.
How about getting rid of them and try to use LEDs to see if either program is getting what it should? Maybe use a couple of switches on one, and LEDs on the other, and get one PIC to follow the other PIC.
Failing that, how about this:
SLAVE
----------------------------------------------------------
Include "Modedefs.bas"
DEFINE OSC 4
DE_OR_RE VAR PORTC.5 ' DE and RE Pin of SN75176
LEDPIN VAR PORTD.2 ' LED to confirm PIC is running
DATARECEIVED VAR BYTE
'======== HSEROUT, HSERIN SETTINGS ==========
DEFINE HSER_RCSTA 90h
define HSER_TXSTA 24h
define HSER_SPBRG 103
DEFINE HSER_CLROERR 1
RCIF VAR PIR1.5:TXIF VAR PIR1.4:ADCON1 = 7:TRISC = %10000000
pause 200:HIGH LEDPIN
Main:
hserin 10,MAIN,[WAIT ("S"),DATARECEIVED] ' Looking for "S0"
IF DATARECEIVED = "0" THEN
HSEROUT ["R1"] ' Send R1
else
hserout ["RZ"] ' Send something to signify SOMETHING received
ENDIF
GOTO MAIN
END
--------------------------------------------------------------------------------
MASTER
--------------------------------------------------------------------------------
Include "Modedefs.bas"
DEFINE OSC 4
DE_OR_RE VAR PORTC.5 ' DE and RE Pin of SN75176
RS232_DEBUG_PIN VAR PORTB.5 ' Debugging to PC
LEDPIN VAR PORTD.2 ' LED to confirm PIC is running
DATARECEIVED VAR BYTE
'======== HSEROUT, HSERIN SETTINGS ==========
DEFINE HSER_RCSTA 90h
define HSER_TXSTA 24h
define HSER_SPBRG 103
DEFINE HSER_CLROERR 1
RCIF VAR PIR1.5:TXIF VAR PIR1.4:ADCON1 = 7:TRISC = %10000000
PAUSE 200:HIGH LEDPIN
Main:
HSEROUT ["S0"] ' Send "S0"
SEROUT RS232_DEBUG_PIN,N2400,["WAITING FOR REPLY..", 13, 10] ' DEBUG TO PC
hserin 100,Main,[WAIT ("R"),DATARECEIVED]
SEROUT RS232_DEBUG_PIN,N2400,["REC:",DATARECEIVED, 13, 10] ' DEBUG TO PC
GOTO Main
END
Bookmarks