Sx-28 serout
Jumpkick
Posts: 19
All of the examples for SEROUT have something like this
SEROUT RA.0, N9600,[noparse][[/noparse] LF,CR,"24C01A",LF,CR]
But that will not compile in SX-Key v3.10 that I am running. How am I supposed to send like that?
Right now in order to send 3 bytes I would end up doing
SEROUT RA.0, N9600,byte1
SEROUT RA.0, N9600,byte2
SEROUT RA.0, N9600,byte3
but that is a very poor design.
Any suggestions?
·
SEROUT RA.0, N9600,[noparse][[/noparse] LF,CR,"24C01A",LF,CR]
But that will not compile in SX-Key v3.10 that I am running. How am I supposed to send like that?
Right now in order to send 3 bytes I would end up doing
SEROUT RA.0, N9600,byte1
SEROUT RA.0, N9600,byte2
SEROUT RA.0, N9600,byte3
but that is a very poor design.
Any suggestions?
·
Comments
Attached is an example of sending bytes and strings. It uses mostly subroutines written by Jon Williams (Forum Moderator). Written for the Parallax Professional Development Board but will work on the SX tech board with a few mods.
Parallax Professional Development Board:
Connect RA.0 to X13-2 (RS-232 driver)
SX Tech board:
In the program change:
PcTxBaud CON "T9600" ' PC Baud Rate (MAX-232) 9600,8,N,1
to:
PcTxBaud CON "N9600" ' PC Baud Rate (INVERTED) 9600,8,N,1
Then RA.0 will go directly to pin 2 on your PC's serial port. You'll need a terminal program to receive the data
Compile the program & program the part, insure the FREQ directive matches whatever type of resonator that you are using. The internal clock is not accurate enough for serial communication so make sure your using a resonator or a crystal.
By putting most SX/B commands in subroutines, will save code space, do a <CTRL>-L to look at the assembly, if your interested.
Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"OEM NMEA GPS Module" Now available on ebay for only $17.49
Product web site: http://www.allsurplus.net/Axiom/
Post Edited (Mike Cook) : 2/18/2006 5:12:01 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
' Use: TX_STR [noparse][[/noparse] string | label ]
' -- "string" is an embedded literal string
' -- "label" is DATA statement label for stored z-String
TX_STR:
· temp1 = __PARAM1····························· ' get string offset
· temp2 = __PARAM2····························· ' get string base
· DO
··· READ temp2 + temp1, temp3·················· ' read a character
··· IF temp3 = 0 THEN EXIT····················· ' if 0, string complete
··· SEROUT SOut, Baud, temp3··················· ' send the byte
··· INC temp1·································· ' point to next character
··· temp2 = temp2 + Z·························· ' update base on overflow
· LOOP
· RETURN
I will update the SEROUT demos to include a string TX subroutine -- this one happens to be in READ because that's a key element of retrieving the string characters from a stored (either inline or in DATA statements) string.· Using this subroutine you can do this:
· TX_STR MyStr
... where MyStr is defined as:
· DATA·· LF, CR, "24C01A", LF, CR, 0
Just make sure you have constant definitions for LF an CR as they are not predefined by the compiler.· You also need to declare the subroutine:
TX_STR··· SUB··· 2
Two parameters are required because the address of the string uses two bytes (base + offset).· You can also use the subroutine above to send inline strings, but they must be enclosed in quotes -- you can't separate elements with commas as in you BS2-style example:
· TX_STR "24C01A"
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 2/20/2006 5:31:52 PM GMT