+ Post New Thread
Results 1 to 5 of 5
  1. #1
    Junior Member level 2
    Points: 1,009, Level: 7

    Join Date
    Feb 2008
    Posts
    24
    Helped
    0 / 0
    Points
    1,009
    Level
    7

    calculating baud rate

    Hi guys,
    I am in trouble of calcualting /obtaining baud rate for serial communication given the oscillator frequency .
    can any one explain it or inform me where to get an illustration?
    10Q!

    •   Alt15th May 2008, 22:36

      advertising

        
       

  2. #2
    Advanced Member level 5
    Points: 14,575, Level: 29
    blueroomelectronics's Avatar
    Join Date
    Sep 2006
    Location
    Toronto, Canada
    Posts
    1,682
    Helped
    178 / 178
    Points
    14,575
    Level
    29

    19200 baud frequency

    For what microcontroller?


    1 members found this post helpful.

    •   Alt15th May 2008, 23:41

      advertising

        
       

  3. #3
    Advanced Member level 5
    Points: 35,219, Level: 45
    Awards:
    3rd Helpful Member
    ckshivaram's Avatar
    Join Date
    Apr 2008
    Location
    villingen (Germany) / Bangalore
    Posts
    5,070
    Helped
    2126 / 2126
    Points
    35,219
    Level
    45
    Blog Entries
    1

    what is pcon.7

    calculation and formulas for baud rates are different for different controllers.
    For 8051 refer mazidi.
    for ARM LPC series, refer data sheet



    •   Alt16th May 2008, 04:03

      advertising

        
       

  4. #4
    Member level 1
    Points: 1,629, Level: 9

    Join Date
    Jul 2006
    Location
    India
    Posts
    38
    Helped
    3 / 3
    Points
    1,629
    Level
    9

    baud rate equation

    Every Microcontroller has its own procedure for calculating Baud Rates for Serial Comminication. It depends on the Clock input for Serial port. Go throughthe data sheet of the Controller you are looking for.



  5. #5
    Junior Member level 3
    Points: 1,136, Level: 7

    Join Date
    Oct 2007
    Location
    Islamabad
    Posts
    28
    Helped
    3 / 3
    Points
    1,136
    Level
    7

    256 baud rate

    from www.8052.com

    Setting the Serial Port Baud Rate

    Once the Serial Port Mode has been configured, as explained above, the program must configure the serial ports baud rate. This only applies to Serial Port modes 1 and 3. The Baud Rate is determined based on the oscillators frequency when in mode 0 and 2. In mode 0, the baud rate is always the oscillator frequency divided by 12. This means if youre crystal is 11.059Mhz, mode 0 baud rate will always be 921,583 baud. In mode 2 the baud rate is always the oscillator frequency divided by 64, so a 11.059Mhz crystal speed will yield a baud rate of 172,797.

    In modes 1 and 3, the baud rate is determined by how frequently timer 1 overflows. The more frequently timer 1 overflows, the higher the baud rate. There are many ways one can cause timer 1 to overflow at a rate that determines a baud rate, but the most common method is to put timer 1 in 8-bit auto-reload mode (timer mode 2) and set a reload value (TH1) that causes Timer 1 to overflow at a frequency appropriate to generate a baud rate.

    To determine the value that must be placed in TH1 to generate a given baud rate, we may use the following equation (assuming PCON.7 is clear).


    TH1 = 256 - ((Crystal / 384) / Baud)
    If PCON.7 is set then the baud rate is effectively doubled, thus the equation becomes:

    TH1 = 256 - ((Crystal / 192) / Baud)

    For example, if we have an 11.059Mhz crystal and we want to configure the serial port to 19,200 baud we try plugging it in the first equation:

    TH1 = 256 - ((Crystal / 384) / Baud)
    TH1 = 256 - ((11059000 / 384) / 19200 )
    TH1 = 256 - ((28,799) / 19200)
    TH1 = 256 - 1.5 = 254.5

    As you can see, to obtain 19,200 baud on a 11.059Mhz crystal wed have to set TH1 to 254.5. If we set it to 254 we will have achieved 14,400 baud and if we set it to 255 we will have achieved 28,800 baud. Thus were stuck...
    But not quite... to achieve 19,200 baud we simply need to set PCON.7 (SMOD). When we do this we double the baud rate and utilize the second equation mentioned above. Thus we have:


    TH1 = 256 - ((Crystal / 192) / Baud)
    TH1 = 256 - ((11059000 / 192) / 19200)
    TH1 = 256 - ((57699) / 19200)
    TH1 = 256 - 3 = 253

    Here we are able to calculate a nice, even TH1 value. Therefore, to obtain 19,200 baud with an 11.059MHz crystal we must:

    1. Configure Serial Port mode 1 or 3.
    2. Configure Timer 1 to timer mode 2 (8-bit auto-reload).
    3. Set TH1 to 253 to reflect the correct frequency for 19,200 baud.
    4. Set PCON.7 (SMOD) to double the baud rate.


    1 members found this post helpful.

+ Post New Thread
Please login