Shop OBEX P1 Docs P2 Docs Learn Events
adding a second stop bit to serout? — Parallax Forums

adding a second stop bit to serout?

SteelSteel Posts: 313
edited 2007-05-14 19:12 in General Discussion
Could anybody help me add a second stop bit to the serout function? Can it be done in·sxb, or does it need to be done in Assembly?

I can't find anything in the SEROUT in·the help file.

Thanks.
Shaun·

Comments

  • JonnyMacJonnyMac Posts: 8,940
    edited 2007-05-14 18:43
    The standard SEROUT uses 8N1; that said, an additional stop bit can be added after your SEROUT by using PAUSEUS for the required bit time. Here's a way to encapsulate SEROUT into a subroutine (which saves code space) and specify the number of stop bits (0 or 1 input will still give one stop bit):

    SUB TX_BYTE
      tmpB1 = __PARAM1
      IF __PARAMCNT = 2 THEN
        tmpB2 = __PARAM2
        IF tmpB2 > 0 THEN
          DEC tmpB2
        ENDIF
      ELSE
        tmpB2 = 0
      ENDIF
      SEROUT TX, Baud, tmpB1
      DO WHILE tmpB2 > 0
        PAUSEUS BitTime
        DEC tmpB2
      LOOP
      ENDSUB
    
    



    Of course, you'll need a PIN definition for TX, and CONstant definitions for Baud and BitTime. Use this declaration:

    TX_BYTE        SUB    1, 2
    



    You may want to use the MAX operator to limit the maximum number of additional stop bits.

    Post Edited (JonnyMac) : 5/14/2007 7:33:13 PM GMT
  • SteelSteel Posts: 313
    edited 2007-05-14 19:12
    Thanks jonnymac.· I was going to do Pauseus, but I guess I just needed to make sure I wasn't missing anything.



    Thanks for the help!

    Shaun
Sign In or Register to comment.