Shop OBEX P1 Docs P2 Docs Learn Events
Serin baud rate — Parallax Forums

Serin baud rate

ArchiverArchiver Posts: 46,084
edited 2002-05-01 15:34 in General Discussion
At 10:34 AM 5/1/02 -0400, you wrote:
>Is it possible to set the serin baud rate to a value other than what's
>in the tables? I need about 900 baud 1 start bit - one stop bit - even
>parity. Maybe some of you that really know the inside of this thing can
>comment. I looked at the table in the manual and didn't get any hints.
>Thanks for you help..
>
>Leroy



You can use this formula to calculate the 'baudmode'


baudmode = (10000/(BAUD/100))-20

Where 'baudmode' is the value the Stamp must use
and 'BAUD' is the ACTUAL baud that you desire.


ie: BAUD = 9600

baudmode = (10000/(9600/100))-20
= (10000/96)-20
= 104-20
= 84

BAUD = 900

baudmode = (10000/(900/100))-20
= (10000/9)-20
= 1111-20
= 1091


Code Example:

baud var byte
baud = 1091
serout 16,baud+$4000,[noparse][[/noparse]"Hello"]



Beau Schwabe Mask Designer IV - ATL
National Semiconductor Enterprise Networking Business Unit
500 Pinnacle Court, Suite 525 Wired Communications Division
Mail Stop GA1 Norcross, GA 30071

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-05-01 14:40
    At 10:34 AM 5/1/02 -0400, you wrote:
    >Is it possible to set the serin baud rate to a value other than what's
    >in the tables? I need about 900 baud 1 start bit - one stop bit - even
    >parity. Maybe some of you that really know the inside of this thing can
    >comment. I looked at the table in the manual and didn't get any hints.
    >Thanks for you help..
    >
    >Leroy

    Here is another copy of an E-mail that I sent out several years ago about
    this subject. Found in the Stamp Archives under a search for "BAUD Formula".
    http://www.jamesrusso.com/stamp/


    "Baudmode is the bit period expressed in microseconds-20 (i.e.300 baud
    is 3313). Baudmode's bit 15 ($8000) is 0 for driven, 1 for open-drain/
    open-source (SEROUT). Baudmode's bit 14 ($4000) is 0 for true, 1 for
    inverted. Baudmode's bit 13 ($2000) is 0 for 8-bit no parity, 1 for 7-bit
    parity"

    396 is the BASE number you need to use for 2400 baud. At 2400 as your
    base number your actual baud come out to something like 413bps

    ...for 2400 baud, 8-bit, no parity, true data, driven output use...
    SEROUT 8,396,[noparse][[/noparse]$3,$0]

    ...for 2400 baud, 7-bit, parity, true data, driven output use...
    SEROUT 8,396+$2000,[noparse][[/noparse]$3,$0]

    ...for 2400 baud, 8-bit, no parity, inverted data, driven output use...
    SEROUT 8,396+$4000,[noparse][[/noparse]$3,$0]

    ...for 2400 baud, 7-bit, parity, inverted data, driven output use...
    SEROUT 8,396+$6000,[noparse][[/noparse]$3,$0]

    ...for 2400 baud, 8-bit, no parity, true data, open drain/source use...
    SEROUT 8,396+$8000,[noparse][[/noparse]$3,$0]


    ...To Calculate the baud number (ie 396) you can use the "stamp friendly"
    formula below. Stamp friendly, because you can use it within a program
    making it easy to change the baud by entering the actual baud (ie 2400)

    BaudValue = (10000/(Baud/100))-20
    = (10000/(2400/100))-20
    = (10000/24)-20
    = 416-20 <- Fractions are truncated
    = 396

    'Program Example:
    Initialize:
    Baud con 2400 '<- actual Baud value
    BaudValue var Word

    BaudValue = (10000/(Baud/100))-20 '<- Parallax Conversion

    MainLoop:
    'Button Detection routines go here
    SEROUT 8,BaudValue,[noparse][[/noparse]$3,$0]
    goto MainLoop
    Beau Schwabe Mask Designer IV - ATL
    National Semiconductor Enterprise Networking Business Unit
    500 Pinnacle Court, Suite 525 Wired Communications Division
    Mail Stop GA1 Norcross, GA 30071
  • ArchiverArchiver Posts: 46,084
    edited 2002-05-01 15:34
    Is it possible to set the serin baud rate to a value other than what's
    in the tables? I need about 900 baud 1 start bit - one stop bit - even
    parity. Maybe some of you that really know the inside of this thing can
    comment. I looked at the table in the manual and didn't get any hints.
    Thanks for you help..

    Leroy
Sign In or Register to comment.