hserout problems

mandsanda

New Member
I am trying to get comms via hserout & hserin.

code snippet:

hserin [990,main],0,8 ‘ receive 8 bytes into scratchpad
ptr = 0 ‘ reset sp pointer
'echo out input
hserout 0,(@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptr)

this works fine - I get back what I send. Interestingly, if I send more or less than 8 bytes, I get only the same number back.

However, something apparently simple doesn't seem to work eg.

hserout 0, (#b0)

or

hserout 0, ("hello")

Any help would be appreciated.

Thanks
 

Janne

Senior Member
Hello,

I don't see anything wrong with your code snippets, that you have posted. The problem might lie somewhere else, so posting your whole test program code should help.
 

hippy

Ex-Staff (retired)
Which PICAXE are you using ? Though I can't say I've noticed any problems with the simpler, #w0 or "hello", HSEROUT commands.

If by "I get only the same number back" you mean you get the number of characters you sent no matter how many there were this may be a result of the timeout or not setting 'ptr' before waiting for HSERIN and multiple executions of HSERIN.

For both issues, posting the full code which demonstrates the problems will be helpful.
 

Technical

Technical Support
Staff member
Make sure you haven't forgotten the initial required 'hsersetup' command on the simpler examples.
 

mandsanda

New Member
thanks for prompt replies.

here is the whole thing.

I get nothing from the 1st four hserout cmds. After I send some data, I get a response from the last hserout which works great.

I am sending and recieving via a XBee RF module. I don't see this as a problem as the last transmission works OK - every time. The Xbees are set for no sleep.

I am using a 28x1 picaxe.

Code:
symbol seconds = b20

HSERSETUP B2400_4, %00	'foreground receive
pause 250
hserout 0, ("Ready for data !!!",CR,LF)

seconds = 0
settimer t1s_4 '1 sec timer

main:
	
	if timer = 60 then
		timer = 0
	endif
	
	hserout 0, ("hello")
	hserout 0, (#b20)
	
	'write timer0 value to scratchpad 8&9
	put 8, timer
		
	'write some data into scratchpad 0-7
	put 0, 0
	put 1, 1
	put 2, 2
	put 3, 3
	put 4, 4
	put 5, 5
	put 6, 6
	put 7, 7
	
	'set the scratchpad pointer
	ptr = 0
	'send dummy values
	hserout 0,(@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptr)
	
	hserin [990,main],0,8 ‘ receive 8 bytes into scratchpad
	ptr = 0 ‘ reset sp pointer
	'echo out input
	hserout 0,(@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptr) ‘ echo out
	
				
	goto main
 

Technical

Technical Support
Staff member
Have you tried sending the data to a computer rather than a XBee, we suspect you will then see it.
How long does an XBee take to power up......, are you allowing enough time at start of program?
 

mandsanda

New Member
I haven't tried directly connecting to a PC - except via programming cable and debug and sertxd commands - which show correct variable values.

The XBee works fine with the recieve then transmit commands at the end of the code- and this 3 line snippet works no matter where I put it.

It doesn't seem to matter whether the 'simple' hserout commands come earlier or later in the program - they just don't feature in any output.

not sure what to try next. I can't use serout on the serial hardware pin so I can't go down that route.


Stumped for now
 
Last edited:

hippy

Ex-Staff (retired)
What exactly have you got connected to the other XBee, how are you determining what's being received or not ?
 

mandsanda

New Member
hserout problem

I have the another Xbee connected to a PC at the other end. I am sending/receiving the data from the terminal window in X-CTU - interface/config program for the Xbee.
 
Last edited:

hippy

Ex-Staff (retired)
I'm wondering if it's something to do with X-CTU. You could try running a simpler program and seeing what that does within X-CTU and with a terminal emulator ( HyperTerm or the Terminal display within Programming Editor ) ...

#Picaxe 28X1
HserSetup B2400_4, %00
Do
Pause 2000
HSerOut 0, ( "Hello", CR, LF )
Loop
 

mandsanda

New Member
Thanks Hippy

Using your simple code, still no joy. Nothing in X-Ctu or hyperterminal. No tx/rx light activity on the Xbee either.

Once again this works on both Hyperterminal and X-Ctu:

#Picaxe 28X1

HserSetup B2400_4, %00

main:
Do
'Pause 2000

hserin [990,main],0,8 ' receive 8 bytes into scratchpad
ptr = 0 ‘ reset sp pointer
'echo out input
hserout 0,(@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptrinc,@ptr,CR,LF) ‘ echo out


HSerOut 0, ( "Hello", CR, LF )
Loop

However, I don't get the CR/LF sent through - only the charachters setnt are echoed. If I send a CR/LF that is echoed back. I never see the "hello".

What to do?

Cheers
 

mandsanda

New Member
My apologies to all.

The #$@##$ Xbee is echoing the sent characters back - even with no picaxe installed in the circuit!!!

I need to delve into the xbee config.

Cheers & thanks
 

mandsanda

New Member
Once again - thanks for all the help.

Problem was a short between RX/TX lines so Xbee echoed all received data without allowing any input/control from picaxe.

Onwards.
 

hippy

Ex-Staff (retired)
No problems and thanks for letting everyone know. Well done for tracking down where the problem lay.
 
Top