© 2001 Ubicom, Inc. All rights reserved.
- 9 -
www.ubicom.com
Asynchronous Transmitter & Receiver (UART) Virtual Peripheral Implementation
AN38
4.0 Baud Rate Generation and Timing
As an example of calculating the parameters which con-
trol the timing of the UART Virtual Peripheral, consider
transmitting data at 14400 baud with four times oversam-
pling (i.e. a sampling frequency of 57.6 kHz).
Transmission time for 1 bit = 1/14400 seconds
The divide ratio
UARTTxDivide for the above example is
the sampling rate divided by the baud rate. The sampling
rate is defined by the interrupt frequency and the number
of slots for the UART virtual peripheral ISR in the multi-
tasker.
So the formula for the
UARTTxDivide and
UARTRxDi-
vide constants is:
UARTTxDivide = UARTTxFs/(UARTBaud)
= 57600/(14400 * 4) = 1
In receive mode, the generation of baud rate is calculated
in the same way, except that a constant called
UARTRx-
StDelay is used to skip over the start bit. This constant is
equal to 1.5 times the baud period. Its purpose is to
ensure that the bits are sampled near the middle of each
pulse.
4.1
Circuit Design Procedure
The simplest version of the circuit requires two port pins
for transmit and receive. If hardware handshaking is
used, additional port lines are required. The hardware
interface only requires a driver for converting the voltage
level of the signals. The same concept can be used to
extend and configure two or more independent UARTs.