test code insert

Hi there,

I am trying to get a protocol going for 2 Picaxe chips exchanging data over Maxstream ZigBee/XStream/XTend RF modems. I have tried all modules and they all work fine sending messages either way but when I try to get one to respond to the others message and so on so on the serial comms gets itself hung up. Eventually I want Module 2 to ask Module 1 some data, Module 2 responds and then Module 1 asks for more data based on what it received. It sounds simple but it keeps locking up.

I have also tried a 2 wire direct input pin to output pin with the same program thus eliminating the possibility of it being the RF modules. The simple code to test the principle sends a number from Module 2 to Module 1 and Module 2 increments it then passes it back to M1. M1 then increments it and sends it back and so on and so on. Please can someone clever have a look at my code and tell me why it starts, runs for a few seconds, freezes, starts again sometimes, stops and generally doesn't seem at all reliable for what I am trying to do. I have tried T2400 as well and I have also tried adding delays in the loop of varying values.

It appears I could be getting a buffer overrun (I think I know what this means, data sent faster than it can be read). I can understand that if this were the case I might not always get consequtive numbers but what happens to the serial line to cause it to hang. I could probably work out how to put in some hardware flow control if it was a 3 wire Picaxe to Picaxe project but with RF in between I am not sure how to do it.

If anyone can help it would be fantastic.

<code><pre><font size=2 face='Courier'>
Module 1:
symbol n = b0
serout 7,T4800,(n) ' gives Module 2 something to process if it is locked waiting for input at startup
counter:
serin 0,T4800,b1
n = b1
if n &lt; 100 then
inc n
else
n = 0
endif
serout 7,T4800,(n)
'pause 100
goto counter

Module 2:
symbol n = b0
n = 0
serout 7,T4800,(n) ' gives Module 1 something to process if it is locked waiting for input at startup
counter:
serin 0,T4800,b1
n = b1
if n &lt; 100 then
inc n
else
n = 0
endif
serout 7,T4800,(n)
'pause 100
goto counter

</font></pre></code>
 
Top