Problem with SX/B compiler using the PAUSE and SEROUT statements
![redface.gif](http://forums.parallax.com/images/smilies/redface.gif)
I need to have a time delay before sending a character string at powerup as part of my application. When I added the PAUSE statement·to·my code to get the delay, I·kept getting a garbled initial character. After a lot of trial and error, I pared the code down to a bare minimum and found that if the·PAUSE comes first, there is a garble every time on powerup, and if the SEROUT comes first, there is never a garbled initial character. Here is my test code:
This works just fine:
DEVICE········· SX28, OSCXT2, TURBO, STACKX, OPTIONX, BOR26
IRC_CAL··IRC_SLOW
FREQ··········· 20_000_000
PROGRAM START
START:
OUTPUT RA.1
MAIN:
SEROUT RA.1,T9600,71
PAUSE 254
GOTO MAIN
This produces an initial garbled character on powerup every time:
DEVICE········· SX28, OSCXT2, TURBO, STACKX, OPTIONX, BOR26
IRC_CAL··IRC_SLOW
FREQ··········· 20_000_000
PROGRAM START
START:
OUTPUT RA.1
MAIN:
PAUSE 254
SEROUT RA.1,T9600,71
GOTO MAIN
Is this an SX/B compiler bug? How can I get rid of this garble and still get an initial time delay before sending after a power up??
·
Comments
As for the garbled character, you should set the pin to the "idle" state before the pause.
Since you are using "true" serial mode that would be high.
Try this
HIGH RA.1
MAIN:
PAUSE 254
SEROUT RA.1,T9600,71
GOTO MAIN
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
COMING SOON "SD DATA LOGGER" www.sddatalogger.com
"I reject your reality, and substitute my own." Mythbusters
·
· PLP_A = %1101
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I tried your suggestions - and they both fix the problem. Like most problems, it's obvious once it is solved, though I wish I could have had this info before I spending three hours trying different code configurations. It makes sense that the send data lead needs to be put in a steady mark (high) condition immediately on startup. I think this needs to be included in the SEROUT documentation.
Thanks again.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 5/9/2006 11:04:35 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
---
James Newton, Host of SXList.com
james at sxlist,com 1-619-652-0593 fax:1-208-279-8767
SX FAQ / Code / Tutorials / Documentation:
http://www.sxlist.com Pick faster!