clock frequency

Discussion in 'Embedded Systems and Microcontrollers' started by Jeeny, Apr 9, 2012.

  1. Jeeny

    Thread Starter New Member

    Apr 9, 2012
    5
    0
    what is the significant of clock frequency in baud rate calculation?? thx
     
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Can you elaborate some.
     
  3. Jeeny

    Thread Starter New Member

    Apr 9, 2012
    5
    0
    i mean how clock freq relate with baud rate calculation? for example the formula of x (SPBRG)=(156250/DESIRED BAUD RATE)-1
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    I guess we are talking about asynchronous transmission here. The baud rate generator use the system clock. The system clock is divided down to create the correct baud, and also correct reading of incoming data.
     
    Jeeny likes this.
  5. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    In many cases, the clock frequency of the UART circuitry is 16 times the baud rate.
    For example, 9600 baud requires a clock frequency of 153,600 Hz.
    If your MCU system clock is 4MHz, the closest you can get to the required clock is to divide 4MHz by 26.
     
    Jeeny likes this.
  6. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    I think I recognize this formula from PIC MCUs. And for a PIC the correct number will actually be 25 to be loaded into the SPBRG. All this is explained in the datasheet UART section
     
  7. @android

    Member

    Dec 15, 2011
    178
    9
    Clock rate is like heart bit! Its nothing but a reference for baud rate generator in the circuit. Simply for any digital circuit you need the CLOCK! That is the root of digitization.
    Hope that helped
     
  8. panic mode

    Senior Member

    Oct 10, 2011
    1,320
    304
    you need clock to generate timing for everything, including the baud rate.

    if your baud rate is 9600 bps (bit per second or Hz) and your clock is 9600 Hz, there is no problem creating proper timing because both things match (even if you won't be able to do anything else).

    but you don't want your micro to run this slow and only do uart. you want it to run as fast as possible and do several things at the "same" time.

    then your clock need to be higher and some multiple of the selected bitrate. if the clock is sufficiently high, getting suitable divider is less of a problem (but still need to be an integer).

    for example, suppose you pick crystal of 32768kHz (commonly found in watches).

    32768/9600= 3.41333

    bad choice, 3.41333 is not an integer. to get correct timing for 9600Hz you need to divide original clock by that weird number and that is hard. when company is designing chip, they try to make things simple so the real estate of the silicon is optimally used and cost of the finished product is low. dividing frequency in digital world is simple using counters. but counters count (and divide by) integers.

    exact division factor depends on structure of circuitry inside the micro controller but the goal is the same - get divisor that will produce correct timing for your baud rate.
    to help you with that, manufacturers publish formula in their datasheet. you just have to use it.

    as an exercise, get few TTL chips and try to make counters with base 4, 8, 16, 10 and 4.75. guess which one will be the hardest to do.
     
  9. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    Couple of corrections:

    1) Watch and RTC crystals are 32768Hz, not 32768kHz.

    2) As I mentioned in post #5, the UART clock is 16 times the baud rate. Hence for 9600 baud, the UART clock is 153600Hz or 153.6kHz. Why is this?
    The transmitter hardware can work with a clock of 9.6kHz but the receiver cannot.
    The receiver needs to detect the leading edge of the UART NRZI data and then clock the data bits in the middle of the data window. The hardware does this by sampling on the 8th clock pulse and at every 16th clock pulse following.

    Many MCU UARTs are driven from the MCU clock which tend to be 4MHz or multiples.
    Hence using an integer divisor of 26, we get a baud rate of 9615 which is off from 9600 by 0.15% and that is well within the signal transmission specs.
     
  10. @android

    Member

    Dec 15, 2011
    178
    9
    And yes, welcome to the forum! Seems like you have joined in this month.
     
Loading...