Shop OBEX P1 Docs P2 Docs Learn Events
baudrate vs speed of UART — Parallax Forums

baudrate vs speed of UART

brianLbrianL Posts: 8
edited 2008-09-12 04:53 in General Discussion
Can anybody explain to me why the baudrate causes the speed to be lower.· if you open the uart class; it shows speed = 25,000/(baudrate·+ 217).· What exactly is this speed.· I'd think that the higher your baudrate the higher your speed, but appararently this isn't the case.·· I've been trying to communicate with a pic coprocessor.· When I used my Basic Stamp II controller the baudrate was 396 which also had documentation that shows that speed is something like 1,000,000/baudrate - 20.· I think the speed has to be the same in order for proper communication.· The java stamp baud rate doesn't have a low enough baudrate to match the BSII speed.· I've tried adding stop bits.· If anybody knows how to match this speed or anything else that I may want to consider trying, please reply.·· I'll have to get an oscilloscope to see the signals being sent.

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-09-09 19:12
    This 'speed' is in fact a divisor value: the lower the value, the higher the baudrate.
    In your BS2 example, 396 yields 2400 baud, so you would use Uart.speed2400
    which sets the uart baudrate to 2400 baud.

    regards peter
  • brianLbrianL Posts: 8
    edited 2008-09-12 01:25
    I finally got a chance to retry my program using 2400 baud rate and you are correct.· My pic is now controlling my motor the way its suppose to.· I had tried every baud rate available before but i've done allot of changing around of my code so maybe it wasn't right when I tried it the first time.· thanks allot
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2008-09-12 04:53
    brianL,

    The number that you "see" is a representation of the Bit rate minus 20us for processing overhead and a scaling factor dependant on the flavor of the BS2 processor used.

    For example....

    9600 baud

    If you take the inverse of 9600 you get ... 104.16us 1/9600 - 104.16us

    Since the Stamp uses integer math, then the closest approximation would be 104us (or 9615 baud)

    Now, because of the 20us overhead required, the 104us becomes 84


    The numbers used appear higher with lower baud rates because the bit period is higher and represented as an inverse value.

    For example....

    300 baud .... take the inverse 1/300 = 3333.33us

    ...round and subtract 20us for the processing overhead and you get 3333 - 20 = 3313

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
Sign In or Register to comment.