Xbee Pro issue (communicating)

temple

New Member
Hello,

Please help!
I'm an amateur.

I have hit a problem. I have to xbee units that I am trying to get communicating. when i only make one send and one receive it works, however, as soon as I try to send data back it causes the program to not respond anymore.

Here is a sample of the code I am using.

TX:
Code:
'TX unit

init:		high 7
		pause 100

main:		let b0=10					'assign value 10 to b0
		let b1=50					'assign value 50 to b1
		serout 7,T2400,($55,$55,b0,b1)	'send to RX unit
		pause 1000
		serin 7,T2400,($55,$55),b5,b6		'RX unit sends value of 100 (b5) and 200 (b6) 
		debug
		goto main
RX:
Code:
'RX unit

init:		high 7
		pause 100

main:		serin 7,T2400,($55,$55),b0,b1 	'receive value of b0 and b1 from TX unit
		debug
		if b0=10 then handshake			'if value data is received then assign value to b5 and b6
		goto main
		
		handshake:
		let b5=100
		let b6=200
		serout 7,T2400,($55,$55,b5,b6)	'send value of b5 and b6 to Tx unit
		pause 1000
		goto main
Thank you,
Temple.
 

hippy

Technical Support
Staff member
Try cahnging your TX routine from ...

- serout 7,T2400,($55,$55,b0,b1)
- pause 1000
- serin 7,T2400,($55,$55),b5,b6

to ...

- pause 1000
- serout 7,T2400,($55,$55,b0,b1)
- serin 7,T2400,($55,$55),b5,b6

and remove the 'PAUSE 1000' from your RX routine.

What's probably happening is that the receiver gets the message and responds, but the transmitter is waiting in the pause, and by the time it has come out of it the data has gone past and it waits forever for data which will never arrive.

If you still have problems, simplify both the sender and receiver. Send just a single byte ( no qualifiers - the $55,$55 ) and have the receiver simply echo back whatever it receives ...

- TxLoop:
- Pause 1000
- SerOut 7, T2400, (b0)
- SerIn 7, T2400, b0
- Goto TxLoop

- RxLoop:
- SerIn 7, T2400, b0
- SerOut 7, T2400, (b0)
- Goto RxLoop

Build up from there.
 
Top