Wednesday, November 15, 2006

8051 microcontroller FAQ

http://www.faqs.org/faqs/microcontroller-faq/8051/
A1: 11.0592 MHz crystals are often used because it can be divided to
give you exact clock rates for most of the common baud rates for
the UART, especially for the higher speeds (9600, 19200).
Despite the "oddball" value, these crystals are readily available
and commonly used.

A2: When Timer 1 is used as the baud rate generator, the baud rates
in Modes 1 and 3 are determined by the Timer 1 overflow rate and
the value of SMOD (PCON.7 - double speed baud rates) as follows:

smod
2
Baud rate = ------ x (Timer 1 overflow rate)
32

Most typically, the timer is configured in the auto-reload mode
(mode 2, high nibble of TMOD = 0100B). In this case, the baud
rate is given as:

smod
2 Oscillator frequency
Baud rate = ------- x --------------------
32 12 x (256 - TH1)

Some typical baud rates for an 11.0592 crystal:

Baud rate SMOD TH1
---------------------
19200 1 0FDH
9600 0 0FDH
4800 0 0FAH
2400 0 0F4H
1200 0 0E8H
300 0 0A0H

Another way to look at it, would be to rework the formula to give
us the crystal frequency that we need for the desired baud rate:

smod
Minimum crystal frequency = Baud rate x 384 / 2

This gives us the minimum crystal frequency possible for the
desired baud rate. The frequency can be evenly multiplied to
obtain higher clock speeds.

As an example, the minimum crystal frequency for 19.2K baud is:
3.6864 = 19200 x 384 / 2 (smod is 1 for 19.2K baud)

11.0592 = 3.6864 x 3


To determine the timer reload value needed, the formula can be
changed to factor in the multiplier:
smod
Crystal frequency = Baud rate x (256 - TH1) x 384 / 2


From the example above, the multiplier (3) is used to determine
TH1:
TH1 = 256 - 3 = 253 = 0FDH

The crystal frequency for 19.2K baud is:
11.0592 = 19200 x (256 - 0FDH) x 384 / 2
(smod is 1 for 19.2K baud)


Other values can also give good results, but 11.0592 is one of
the higher speed crystals that allows high baud rates.

No comments: