28x1 hserin help?

flak

New Member
Hi i have problem im using a 433mhz tx and rx pair to send a qualifier byte + 6 bytes of data the serin command works fine however when i use the hserin command with the same qualifier byte + baud rate the data is incorrectly received.I need the hserin to put 6 bytes into scratch pad in the background so that it doesn't stop the main program at serin waiting for data.


TX code
Code:
symbol TX_POWER = c.6
symbol TX_PIN =  c.7
symbol TX_BAUD =  N1200_4

main:
high TX_POWER
serout TX_PIN,TX_BAUD,("UUUUUUUUUUUUUUUUUU","D",67,68,69,70,71,b1)

low TX_POWER

pause 1000
inc b1
goto main


hserin RX code
Code:
main:
hsersetup B1200_4,%00

hserin 0,6,("D")

ptr = 0 ; reset sp pointer

get 0,b18
get 1,b19
get 2,b20
get 3,b21
get 4,b22
get 5,b23

sertxd("hserin data ",#b18," ",#b19," ",#b20," ",#b21," ",#b22," ",#b23,13,10)

pause 10
goto main
 

Chavaquiah

Senior Member
hsersetup B1200_4,%00

With hsersetup, you're leaving bit1 of mode at zero. This will make hserin expect a non-inverted signal. Either use T1200_4 on the sender or try hsersetup B1200_4,%10.
 

hippy

Ex-Staff (retired)
As Chavaquiah says. It's best to invert the polarity of the receiver, that is, alter the %00 to %10.

Note however that HSERIN 0,6,("D") is a blocking command, the program will stop while waiting for data just as SERIN would.
 

flak

New Member
So does that mean that even though hserin reads bytes in the background it will still stop the main program execution as well not just the hserin thread if it has a qualifier to wait for,doesn't that defeat the purpose of hserin ?

If the above is true then how do you read in data with a qualifier in the background on a x1 part without it disturbing the main program from a noisy rx module for example ?
 

Chavaquiah

Senior Member
I think that only X2 parts can receive serial data in the background. For the 28X1, even with hserXXX, don't know if there is much else you can do...
 

hippy

Ex-Staff (retired)
So does that mean that even though hserin reads bytes in the background it will still stop the main program execution as well not just the hserin thread if it has a qualifier to wait for
That is correct.

doesn't that defeat the purpose of hserin ?
Not really as HSERIN has multiple uses and various reasons for using it, in particular its ability to use various baud rates beyond what SERIN offers.

If the above is true then how do you read in data with a qualifier in the background on a x1 part without it disturbing the main program from a noisy rx module for example ?
You need to let the data accumulate in the scratchpad while scanning the scratchpad looking for the qualifier and data, that will get rid of the noise received. You will have to activate interrupts to do the scanning when data is received or otherwise work that into your main loop somehow.

The best option is to add a 'front-end buffer' between receiver module and PICAXE which ensures there will be no noise getting to the PICAXE in the first place. I've usually suggested that an additional PICAXE is used to achieve that but the AXE213 RF Connect can now serve that purpose.
 
Top