Shop OBEX P1 Docs P2 Docs Learn Events
Newbie question about SERIN and SEROUT — Parallax Forums

Newbie question about SERIN and SEROUT

SSchafferSSchaffer Posts: 12
edited 2007-10-26 13:36 in BASIC Stamp
Hello,
···· I am trying to write a program for my BS2 Homework Board that accepts and transmits data through a RS232 connection from a Com Port. I have been reading over the explanations for SERIN and SEROUT in the Basic Stamp Syntax and Reference Manual 2.2, and am confused by something: It says that if I specify the value of RPin (for SERIN) as 16, then "the BASIC Stamp uses the dedicated serial-input pin (SIN, physical pin 2), which is normally used by the Stamp Editor during the download process."

···· This seems like a simple way of using the Serial Cable that I use to program the BS2 for transmitting data via Hyperterminal. What I am wondering is that if I specify the value as 16, will I cause a problem for the BS2 because when it is powered up, it will be running the program I last downloaded to it and will be waiting for serial data constantly, and I will never be able to download any new program to it because I specified the pin the Basic Stamp compiler uses to download programs?

···· Does this make sense? Thanks for any help you can provide.

Scott

Comments

  • JDJD Posts: 570
    edited 2007-10-25 17:35
    Scott,

    Good Question. When you download a new program to the Basic Stamp from the editor; the stamp will stop running with a reset command from the editor. That Stamp will then wait to be reprogrammed, and will run the new program once the download is complete.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Joshua Donelson

    www.parallax.com
  • allanlane5allanlane5 Posts: 3,815
    edited 2007-10-25 18:11
    Yes, that makes sense. What you're missing is that the PC controls pin DTR, and the PC (and the Parallax IDE) will use the DTR pin to 'RESET' your BS2 just before trying to program it.

    So, even if your program IS running when you power up your BS2 (and continues to run), when the IDE tries to reprogram your BS2, it will 'grab' control from your program with the RESET signal.

    If your BS2 is controlling a robot, sometimes it's nice to be able to download a 'do-nothing' program, like:

    MAIN:
    PAUSE 1000
    GOTO MAIN

    -- The advantage of this program is that it will replace any "robot control" program in the BS2, and insure your robot waits patiently for your REAL program to be loaded.

    Oh, and the IDE can do this even IF you are using the "SEROUT 16 ...." command to send data out the serial port, or if your BS2 is 'hung' waiting for data in a "SERIN 16 ..." statement.
  • tabbotttabbott Posts: 26
    edited 2007-10-25 21:38
    Using that pin can be useful!
    In my application, the stamp circuit is buried in an electrical cabinet on the plant floor. The area is electrically very noisy and the program occasionally freezes; it appears that the program pointer jumps to an invalid address. (Which is rather frustrating, and no amount of shielding seems to help). When that happens I have that pin's state remotely cycled, which resets the program and gets the machine back on track with minimal downtime - I don't have to hunt down the box and its power source.
  • SSchafferSSchaffer Posts: 12
    edited 2007-10-26 13:36
    Thank you very much for you answers!

    Scott
Sign In or Register to comment.