Shop OBEX P1 Docs P2 Docs Learn Events
SERIN with Optional Timeout — Parallax Forums

SERIN with Optional Timeout

JDOhioJDOhio Posts: 72
edited 2008-02-27 13:47 in General Discussion
Greetings,

I am using the SERIN command with the optional timeout parameter:
SERIN rb.0,T38400,temp1,50,NoMoreBytes




This code will place received data in temp1, or jump to the label NoMoreBytes if it does not receive data after 50 ms.

The help file indicates that the Timeout parameter can be a byte or word variable so I'd like to use:
SERIN rb.0,T38400,temp1,theTimeOut,NoMoreBytes




Here, the Word variable holds the amount of time that SERIN waits. Since its a variable, I can change it in the program. When I try this, the assembly code gives me the impression that it does not use the value in the variable. Have I misinterpreted the Help file?

Thanks,

Joe

Comments

  • BeanBean Posts: 8,129
    edited 2008-02-26 12:19
    Joe,
    · I have verified the problem you described.
    · The SERIN does not handle WORD variables for the TIMEOUT parameter correctly.

    · If the timeout is·< 256 then use a BYTE variable.
    · If the timeout must be > 255 then put this line just before the SERIN command:

    __WPARAM12 = theTimeOut + 256
    

    This will load the __PARAM1 and __PARAM2 variables with the correct timeout value.

    Let me know if this works for you.

    Bean.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.iElectronicDesigns.com

    ·
  • FORDFORD Posts: 221
    edited 2008-02-27 00:34
    Hi Bean,

    I've been away from the forum a while, and was browsing and this post attracted my attention.

    As there is now a timeout for serin with SXB, what new documentation is there for the newest SXB, or do I just get the latest editor ?

    This is great news for me.

    Cheers,
    Chris, WA.
  • JDOhioJDOhio Posts: 72
    edited 2008-02-27 03:03
    Bean,

    Thanks for the suggestion! Here's an update.

    I didn't try exactly what you asked so I can't say that it works or does not work. In my application, I wanted to wait for a Serial response for about 2 seconds and when I begin to receive it, I want to change the timeout to 10 milliseconds. So I had

    __WPARAM12 = theTimeOut + theExtra
    
    



    where the variable named 'theExtra' has a value of 256 when 'theTimeOut' is 2100. When I begin to receive information, I change 'theExtra' to 0, and 'theTimeOut' to 10. I want to try just what you suggested tomorrow.

    Joe
  • BeanBean Posts: 8,129
    edited 2008-02-27 13:47
    Chris,
    · You can download the latest compiler and the documentation (HTML or PDF) from this thread
    · http://forums.parallax.com/showthread.php?p=597707

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.iElectronicDesigns.com

    ·
Sign In or Register to comment.