Hser Setup - Am I stupid ?????

manie

Senior Member
Am I stupid ? I want to setup Hserial with background receive for a ASK receiver and for sending data with ASK transmitter from Dorji (887 Rx and 888 Tx).

However, I receive NOTHINGon Hserial, but on normal serin and serout it works fine. I need the background receive mode so what am I doing wrong ??
I have had the baud rate for 1200_8, 2400_8, 4800_8 but nothing seems to work.

I have tried :

hsersetup B1200_8 %111 'receive inverted as well as transmit, all with background receive

Can anyone help ?
 

hippy

Ex-Staff (retired)
Hard to say what's wrong without more details. Post your code which works and the code which doesn't and members can take a look at that.
 

inglewoodpete

Senior Member
Hi Manie, If you want to know the answer to that you should have chosen the post a poll option, found at the bottom of the "Start a new thread" page.:)

Here is the code I used on a 40X2 a couple of years ago:

Code:
	'Initialise serial uplink
	HSerSetup B9600_32, %00001	'%abcde where, for X2 chips:
	'				 Bit e (bit 0): Foregrd/Backgrd mode	e=0 foreground;	e=1 background
	'				 Bit d (bit 1): *Transmit mode -	d=0 No invert;	d=1 Invert transmit
	'				 Bit c (bit 2): *Receive  mode -	c=0 No invert;	c=1 Invert transmit
	'				 Bit b (bit 3): disable hserout		b=0 enable;	b=1 disable
	'				 Bit a (bit 4): disable hserin		a=0 enable;	a=1 disable
	'
	HSerInFlag = 0			'Reset serial reception flag
	'
	'later.....
	'
	If HSerInFlag = 1 Then		'Serial data received from Max
		GoSub FetchData		'Fetch the data from the scratchpad using Get or @ptr
	Endif
 

manie

Senior Member
Code that works:
Receiver:

setfreq m8

main:

serin [2000],b.6,N1200_8,("ABC"),b2,b3,b4
if b2<>0 and b4<>0 then
select case b2 'immediately decode for action
Case 42
select case b4
case 109
sertxd("b2= ",#b2," and b3= ",#b3," and b4= ",#b4,13,10)
for b0=1 to b3
high b.7
pause 250
low b.7
pause 250
next b0
end select
end select
end if
b2=0
b3=0
b4=0
goto main


'------------------
Transmitter:

high b.7
pause 2000
setfreq m8
low b.7
main:

serout c.0,N1200_8,(85,85,85,85,85)
pause 1000
serout c.0,N1200_8,(85,85,85,85,"ABC",42,2,109)
high b.7
pause 500
low b.7
pause 10000
serout c.0,N1200_8,(85,85,85,85,"ABC",42,3,109)
high b.7
pause 500
low b.7
pause 5000
goto main

'------------------

Code that does NOT work:
Receiver:
setfreq m8

hsersetup B1200_8,%00111
hserptr=0
hserflag=0
setintflags %00100000,%00100000


main:
pause 100
goto main

'------------------

Interrupt:

pause 100
get 0,b0,b1
pause 100
hserout 0,(b0,b1)
select case b0 'immediately decode for action

Case 30
sertxd("b0= ",#b0," and b1= ",#b1,13,10)
for b2=1 to b1
high b.7
pause 200
low b.7
pause 200
next b2
end select

b0=0
b1=0

setintflags %00100000,%00100000
hserptr=0 'operations data stored below RAM 100
hserflag=0

return

Transmitter:

high b.7
pause 1000
setfreq m8
low b.7
hsersetup B1200_8,%00111
hserptr=0
hserflag=0
setintflags %00100000,%00100000
main:

pause 1500
hserout 0,(85,85,85,30,2)


------------------

Interrupt:

pause 25
get 0,b0,b1
if b0=30 and b1=3 then
high b.7
pause 150
low b.7
end if

b0=0
b1=0

setintflags %00100000,%00100000
hserptr=0 'operations data stored below RAM 100
hserflag=0

return

Any help will be appreciated, Tanks in advance..........
 

Technical

Technical Support
Staff member
the transmitter code is dodgy - what happens after these two lines:

pause 1500
hserout 0,(85,85,85,30,2)
....> fall into interrupt
 

manie

Senior Member
Technical
I seem to have lost the "Goto Main" part when pasting. Other than that anything else wrong ??

Edit to add:
Inglewoodpete: That code is good for "T1200_8" baud. I require inverted "N1200" instead. That seems to be the problem.....
 

hippy

Ex-Staff (retired)
Nothing is received.
How are you determining that ?

I am not sure what the exact problem may be but can think of a number of potential issues; particularly not handling the qualifiers and filtering out noise and garbage in the background receive.

Start with some simpler code, hard-wired link rather than wireless. Start by sending just one byte every second, then build up until you are able to receive everything you would be sending over RF.
 

manie

Senior Member
Hippy
I have done just that, funny thing is, when I switch to normal serin/serout (on hserial pins) it all works fine.
Is my hsersetup correct for inverted background receive/send ??
Edit
And sorry, looking with sertxd on terminal screen shows NOTHING happening.
 

hippy

Ex-Staff (retired)
Your HSERSETUP looks okay. Not seeing anything on the terminal would simply mean you aren't executing any SERTXD commands, or they are executed before the terminal opens and not again. As Technical suggests, put a SERTXD before the SELECT CASE so you can tell if anything is received, even if not the desired data.

The SEROUT/SERIN may work, but that's doing things differently than using HSERIN/HSEROUT so they are not exactly equivalent. In fact, all the RF pre-conditioning you do for the SEROUT transmitter is not being done when sending using HSEROUT. Assuming these are just dumb RF modules that could mean that the receiver never passes the data you expect to the PICAXE.
 

manie

Senior Member
Rossko57
That is an idea I can try, thanks.

To everyone else, thanks for your input, I will try some more, if hsersetup is OK then it is something else. Will keep looking........
 
Top