This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UART frequency.

Hi,

I have read in a book "Serial Port complete, 2nd edition" that the clock of UART should be 16 times the baud rate. but i have never seen any microcontroller in which we set the frequency of UART before configuring it for specific baud rate.!!! So,


1) Why the frequency should be 16 times the baud rate??

2) Can you give me an example (of any microcontroler) where we set the UART frequency???

2) What the purpose of setting clock frequency to UART if we have timers??? Like we generate baud rate in simple 89c52 through timer1 and we don't set any frequency!!!!

  • Also whats the idea of setting the baud rate with timer like we do in 89c5x. how it is link to uart frequency???
  • Hello Khan

    Maybe with this figure you can have better idea how this protocol works. In case of the asynchronous systems, the transmitter uses an internal clock to determine when to send each bit and receiver detects the falling edge of start, then uses its internal clock to read the following bits near their centers. Asynchronous transmissions require each computer to have its own clock. All communications protocols have an specification, in this case this is part of the specification of UART.

    This is useful because this is an asynchronous communication system and is hard to be synchronous with the receiver, then these systems use  something like oversample.

    Please, check next link (ww1.microchip.com/.../en026583.pdf) where you can find information regarding to UART mode in a microcontroller, check page 21-9.

    If you see from the other view, the timers are frequency dividers and the UART use that one, it divide the clock frequency by 16 and generate the baud rate.

    These systems have some standard baud rates, like 115200 bps and some devices can generate different baud rates with the same clock frequency.

    I hope this information can help you and let me know if you have any other questions.

    Regards

    Francisco

  • The Figure that I told you is on page 12 of this datasheet www.ti.com/.../tl16c752d.pdf (Figure 7)

    Regards
    Francisco
  • The link is dead (http://ww1.microchip.com/downloads/en/DeviceDoc/en026583.pdf))... also your answer doesn't explain why the clock frequency should be 16 times the baud rate. also it doesn't clearly mention the need of clock if we have timers etc. kindly review my questions.

  • Hello Khan

    I tested the link and is working, this is an specific module of the UART included in a microcontroller, you can find this information in different datasheet of microcontrollers that include this option. The relationship between baud rate generator and clock frequency is part of the specification of the Universal Asynchronous Receiver Transmitter. Some UART devices include a prescaler that let you divide more the frequency and let you generate more baud rates values, maybe you can have better idea with figure 22 of page 24 of the same datasheet (www.ti.com/.../tl16c752d.pdf). The clock and timer are different things. If you want to generate a timer you will need a clock (reference signal). I let you an small tutorial regarding to timer in a microcontroller (www.microcontrollerboard.com/pic-timer0-tutorial.html) and in the most of microcontroller (or UART device), you put a physical xtal with specific value of frequency, some microcontrollers include the oscillation system inside of the chip.
    So, in order of your questions, could be something like this:

    1) Why the frequency should be 16 times the baud rate??
    Is part of the specification of UART

    2) Can you give me an example (of any microcontroler) where we set the UART frequency???
    ww1.microchip.com/.../en026583.pdf

    2) What the purpose of setting clock frequency to UART if we have timers??? Like we generate baud rate in simple 89c52 through timer1 and we don't set any frequency!!!!
    You won't set the clock frequency, you will chose a clock frequency in base of the baud rate that you want to generate, the baud rate generator is something like a timer (takes the frequency and divide by 16 and other extra value) sometimes the divider doesn't gave you an exactly value of baud rate that you want, that's why they include an extra prescaler and let you generate smaller values and that's why exist some xtals with values like 1.8432MHz.

    I hope this information can help you and let me know if you have any other questions.

    Best regards
    Francisco