Shop OBEX P1 Docs P2 Docs Learn Events
Problem with SX/B compiler using the PAUSE and SEROUT statements — Parallax Forums

Problem with SX/B compiler using the PAUSE and SEROUT statements

tdoddstdodds Posts: 12
edited 2006-05-09 21:59 in General Discussion
redface.gif·HELP!
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

  • BeanBean Posts: 8,129
    edited 2006-05-09 02:24
    First of all you don't have to set the pin to an output. The SEROUT command will do that.
    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
    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-05-09 02:27
    Maybe you need a pull-up on your serial line so that it's in a stable state (vis-a-vis your receiver) until the SX can start transmitting on it.· You could enable the weak pull-up on RA.1 like this

    · PLP_A = %1101

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • tdoddstdodds Posts: 12
    edited 2006-05-09 03:28
    Thanks so much you guys!

    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 WilliamsJon Williams Posts: 6,491
    edited 2006-05-09 04:07
    I don't like to burden our documentation unnecessarily, but will consider adding a note to the modes section·that serial I/O pin *may* need a pull-up or pull-down for proper operation of the attached device.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax

    Post Edited (Jon Williams (Parallax)) : 5/9/2006 11:04:35 PM GMT
  • James NewtonJames Newton Posts: 329
    edited 2006-05-09 21:59
    tdodds, Feel free to add that documentation to an appropriate page on the sxlist.com wiki/blog site. We like our docs heavily loaded with the things users actually trip up on.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ---
    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!



Sign In or Register to comment.