Shop OBEX P1 Docs P2 Docs Learn Events
SERIN/SEROUT flowcontrol? — Parallax Forums

SERIN/SEROUT flowcontrol?

ShredderShredder Posts: 19
edited 2006-08-22 21:12 in BASIC Stamp
So I am still working on the problem of communicating between two micros. I dumped the ooPic for now just to see if I could get two Basic Stamps to communicate.
I am still having a problem with flow control it appears tho.
The code I am using to test was taken from the BS manual..

Here is the code for the BS2PX thats sending the SEROUT

SO PIN 5 ' serial output
FC PIN 7 ' flow control pin
#SELECT $STAMP

#CASE BS2PX
T9600 CON 396
#ENDSELECT

Inverted CON $4000
Baud CON T9600 + Inverted
Main:
DO
SEROUT SO\FC, Baud, [noparse][[/noparse]"Hello!", CR] ' send the greeting
LOOP ' repeat forever
END




And here is the code for the BS2SX thats recieving with SERIN
SO PIN 2 ' serial output
FC PIN 4 ' flow control pin
#SELECT $STAMP

#CASE BS2SX, BS2P
T9600 CON 240

#ENDSELECT
Inverted CON $4000
Baud CON T9600 + Inverted
dataIn VAR      Word(10)

Main:
SERIN SO\FC, Baud, [noparse][[/noparse]dataIn] ' send the greeting
DEBUG dataIn
END



It will only send one character, If I keep pressing run in Stamp Editor 2.2.5 the debug prints out the next character, then the next, and so on.. looping. Is just the inclusion of the pin for flow control all thats needed? or do I need to add something else?

Comments

  • ShredderShredder Posts: 19
    edited 2006-08-22 03:54
    and oh yeah.. I tried it both "+ Inverted" and not inverted
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2006-08-22 05:43
    Shredder, on the input side, try a loop...

    Main:
    DO
      SERIN SO\FC, Baud, [noparse][[/noparse]dataIn] ' receive any char 1 by 1
      DEBUG dataIn
    LOOP
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • ShredderShredder Posts: 19
    edited 2006-08-22 17:21
    I am sure that will work.. but shouldnt it be able to send and receive the whole string? isnt that what flow control is for?
    And if I have to do a loop, it would have to exit the loop at some time.. so maybe when it gets the carriage return "CR"?
    how do I test for that? is it just

    While (dataIn != CR)
    

    ?
  • Tom WalkerTom Walker Posts: 509
    edited 2006-08-22 19:18
    The Stamp does not have ANY native capability for working with strings...chars are about the best you can do without dealing with your own packing routines. The flow control mechanism is for dealing with devices which are too fast or too slow to communicate with the Stamp and basically act as a traffic cop "at the bit level".

    HTH

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...
  • ShredderShredder Posts: 19
    edited 2006-08-22 19:55
    hmm so I am back where I was then with the ooPic..
    But it doesnt have a problem sending a string right? just recieving one?

    I connected the pins to the recieve (pin 2) and the CTS (pin 7) on the serial cable going into my computer and ran hyper terminal..
    the whole string comes across and teh carriage return.. so maybe the ooPic and the BS both have a hard time recieving strings.

    Post Edited (Shredder) : 8/22/2006 8:00:33 PM GMT
  • Tom WalkerTom Walker Posts: 509
    edited 2006-08-22 20:39
    A "hard time" may be exaggerating a little...as Tracy showed, putting SERIN in a loop can get more than 1 character and using multiple variables can do the same...each with its own limitations...and the SX has the·SPSTR addition which can remove most of those....

    Also, depending on what, specifically, you are trying to accomplish, there may be a solution which doesn't require more than 1 character to be transferred...especially if you are controlling both sides of the conversation.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...
  • ShredderShredder Posts: 19
    edited 2006-08-22 21:12
    Yeah I am controlling both sides of the conversation, so I can use a single character.. I am just a problem solver and it bugs me when I cant solve the problem the way I think it should solve [noparse];)[/noparse]
Sign In or Register to comment.