Shop OBEX P1 Docs P2 Docs Learn Events
Baud Rates Beyond 9600 For BS2px — Parallax Forums

Baud Rates Beyond 9600 For BS2px

heroldherold Posts: 66
edited 2005-06-03 04:24 in BASIC Stamp
Can you give me the BAUD rates and the values for the BS2px above 9600 Baud for the SEROUT command, I can't find them in the manual.
·

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-03 01:18
    Remember that the BASIC Stamp can do any baud within it's range, and each group of modules has it's own baud formula that you will find under SERIN and SEROUT in the manau.· For the BS2px, the formula is: INT(4,000,000 ÷ baud rate) - 20.

    I've precalculated the most popular baudmodes for use in my programs, and have embedded them into a Conditional Compilation block that is part of my template file.· I find it far easier to delete this section if I don't need it than to have to calculate or look up baud parameters.

    #SELECT $STAMP
    · #CASE BS2, BS2E, BS2PE
    ··· T1200······ CON···· 813
    ··· T2400······ CON···· 396
    ··· T4800······ CON···· 188
    ··· T9600······ CON···· 84
    ··· T19K2······ CON···· 32
    ··· TMidi······ CON···· 12
    ··· T38K4······ CON···· 6
    · #CASE BS2SX, BS2P
    ··· T1200······ CON···· 2063
    ··· T2400······ CON···· 1021
    ··· T4800······ CON···· 500
    ··· T9600······ CON···· 240
    ··· T19K2······ CON···· 110
    ··· TMidi······ CON···· 60
    ··· T38K4······ CON···· 45
    · #CASE BS2PX
    ··· T1200······ CON···· 3313
    ··· T2400······ CON···· 1646
    ··· T4800······ CON···· 813
    ··· T9600······ CON···· 396
    ··· T19K2······ CON···· 188
    ··· TMidi······ CON···· 108
    ··· T38K4······ CON···· 84
    #ENDSELECT

    SevenBit······· CON···· $2000
    Inverted······· CON···· $4000
    Open··········· CON···· $8000

    Baud··········· CON···· T9600




    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Beau SchwabeBeau Schwabe Posts: 6,557
    edited 2005-06-03 04:24
    herold,

    This is really a matter of personal preference, but I usually do something like this in my code....

    '------------------------------------------------------
    'Initialize varaibles
    
     
    BaudRate      CON 9600
    Bs2Baud       VAR   W0
     
     
    '------------------------------------------------------
    'Calculate BS2Baud
     
    Bs2Baud = BaudRate / 100
    Bs2Baud = 40000 / Bs2Baud
    Bs2Baud = Bs2Baud - 20
    Bs2Baud = Bs2Baud + 16384 'Inverted Mode
     
     
    '------------------------------------------------------
    'Main program goes below here
     
    

    ...Just be sure and keep your BaudRate to something evenly divisible by 100


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Beau Schwabe
    Parallax IC Layout Engineer
Sign In or Register to comment.