Shop OBEX P1 Docs P2 Docs Learn Events
Serial Port question — Parallax Forums

Serial Port question

firestorm.v1firestorm.v1 Posts: 94
edited 2007-05-14 21:27 in BASIC Stamp
Is there a way to get the BS2 to open a pin for serial data in without having to send a CR/LF at the end of each character?

Comments

  • FranklinFranklin Posts: 4,747
    edited 2007-05-14 00:51
    Not sure what you mean. Do you mean in to the stamp or in from the stamp. I believe both are possible, we just need to know what you are trying to do so we can be more specific.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2007-05-14 04:11
    oops, sorry, was drooling at the electronics goldmine website at time of posting.. :P

    I am thinking about designing an interface circuit using a BS2 to go between a PC and an LCD. I was wondering if there is a way for the BS2 to be "listening" for any character rather waiting for an "CR/LF" in order to continue processing.

    Example, if my code is:
    SERIN 1, 16780, [noparse][[/noparse]sData]

    My experience has been that the BS2 will wait for a character, then a CR/LF in order to continue the program.

    What I want to do is have it wait for any character, then once it receives it, continue with the program without waiting for the CR/LF. Do you know if that is possible or is that something I will need to code around?
  • bennettdanbennettdan Posts: 614
    edited 2007-05-14 04:58
    The SERIN line of code should not stop the code if its in the same loop as the rest of the code.
  • AmaralAmaral Posts: 176
    edited 2007-05-14 12:22
    Take a look at the manual on SERIN - WAIT instruction , I'm not sure what you are trying to do but nothing tells me that you have to wait for an CR/LF to keep running.

    Another thing, if you use modifiers , such as DEC(n), if any character other than Number will exit the Serin Command


    Hope to Help


    Amaral
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-05-14 17:50
    Hi firestorm, serin will wait until the conditions in brackets are satisfied. In your example (SERIN 1, 16780, [noparse][[/noparse]sData]
    ) the satisfying condition would be one byte, program flow would then continue.

    sData would then contain the ascii value of the transmitted byte. (example transmit "A" sData contains 65, transmit 6 sData contains 54, transmit 63 sData contains 54).

    You see by the example that if you are only transmitting alpha data one letter at a time it works fine, for numeric data anything over 9 your example code only catches the first digit (byte).

    The serin formatters (wait,DEC,STR stc.) add the flexibility to convert your incoming data "on the fly" and accept strings of varying lengths and types. The CR/LF are sometimes useful tools to determine the end of string but not absolutly neccessary.

    Jeff T.
  • firestorm.v1firestorm.v1 Posts: 94
    edited 2007-05-14 21:27
    Unsoundcode: What I'm going to be doing is something like this:

    Get a character from the serial port,
    Process depending on char received, if control character (^g) then wait for command to follow otherwise print char on LCD depending on options set in memory.
    Repeat as necessary.

    IIRC, any character is a single byte, and can be received by using SERIN, right?

    Thanks for all your help everyone!
Sign In or Register to comment.