82C52 Programmable UART
82C52 Programmable UART
PAGE
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4
1.0 GLOSSARY OF DATA COMMUNICATION TERMS . . . . . . . . . . . . . . . . . . . . . 4
1.1 Clear to Send . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 Data Set Ready . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Data Terminal Ready . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Framing Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.5 Interrupt Driven I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.6 I/O Polling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.7 Overrun Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.8 Parity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.9 Parity Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.10 Percentage Error in Baud Rate Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.11 Request to Send . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.0 CONTROL REGISTERS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1 UART Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Baud Rate Select Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3 Modem Control Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.0 STATUS REGISTERS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1 UART Status Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.2 Modem Status Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.0 TRANSMIT/RECEIVE BUFFER REGISTERS . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.1 Receiver Buffer Register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.2 Transmitter Buffer Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5.0 I/O MAPPED ADDRESSING. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5.1 I/O Mapped Addressing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5.2 Memory Mapped I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5.3 I/O Addressing for the 82C52 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
6.0 RESET OF THE 82C52. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
7.0 PROGRAMMING THE 82C52 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
The 82C52 CMOS Programmable UART can be utilized for This is an output signal generated by the 82C52. Its purpose
serial communications at data rates from DC to 1M baud is to inform the target (i.e. modem) that it is ready for
using clock speeds in the range of 0-16MHz. In addition, the communications.
device provides an internal baud rate generator. 1.4 Framing Error:
In the following discussion, we will look at the functional Each time the 82C52 receives a character of data, it will
capabilities of the 82C52, and give information on how the check for 3 types of errors: (1) Parity error, (2) Framing error,
device can be programmed. The following topics will be and (3) Overrun error.
discussed:
When reading characters through the Serial Data In (SDI)
(1) Glossary of communications terms pin, the 82C52 will first encounter a start bit. This start bit is a
(2) Control registers logical zero, and is detected by the first falling edge of the
signal on SDI. Next, the 82C52 will see a specified number
(3) Status registers of data bits followed by the parity bit. The parity bit is
(4) Transmit/Receive Buffer Registers checked for a parity error (see 1.8 and 1.9). The stop bits are
then checked for a framing error.
(5) I/O Addressing methods
A framing error occurs when an incorrect stop bit is found, or
(6) Reset of the 82C52 if there are too few stop bits. This happens most often when
the baud rates between the communicating devices differ.
(7) Programming the 82C52
The data will have a tendency to become skewed. For
information on this skewing problem, see 1.10.
1.0 Glossary of Data Communication
1.5 Interrupt Driven I/O:
Terms
This is a method of handling interaction between a CPU and
1.1 Clear to Send (CTS):
an I/O device. In this scheme, the I/O device will issue an
Clear-to-send is an input signal to the 82C52. It is provided interrupt to the CPU when it requires attention.
by the device with which the 82C52 is communicating, such
With the 82C52, an interrupt might occur when (1) the device
as a modem. When this signal is in its active state (active
receives a character on its SDI pin, (2) the device completes
low), the 82C52 is being told that the modem will accept data
transmission of a character, (3) an error is found in a
sent to it from the 82C52 Serial Data Out (SDO) pin.
received character, or (4) a change was detected in one of
The CTS signal is specified in the RS-232C protocol and is the modem control lines.
used in conjunction with the Request to Send (RTS) signal. After the interrupt is recognized by the CPU, it (the CPU) will
This signal is used mainly in half-duplex systems. In a half- go to the corresponding Interrupt Service Routine(ISR). This
duplex system communications can be performed in both routine decides how the interrupt should be serviced, and
directions, but in only one direction at a time. then services it. Upon completion of the ISR, execution of
To illustrate this: Suppose we are using the 82C52 to the user’s software will resume at the point where the
communicate over an RS-232C link to a modem. In half- interrupt occurred.
duplex operation the UART tells the modem that it wishes to 1.6 I/O Polling:
transmit a character by putting RTS into its active state
(active low for the 82C52). The modem, if ready for the data, A second method for handling interaction between a CPU
will respond by driving the 82C52’s CTS line to its active and an I/O device. Rather than waiting for an I/O device to
state (low). When the 82C52 recognizes this, it will then interrupt the CPU, the software assumes the responsibility of
begin data transmission. checking to see if an I/O device needs servicing.
1.2 Data Set Ready (DSR): When the system software needs to output to the 82C52, it
will poll (look at) the device to see if it is ready to accept
This is also an input signal to the 82C52. When in its active data. Similarly, in order to receive data from the 82C52, the
state, it signifies that the device with which it is to communi- software will poll to see if there is any data waiting to be read
cate is powered on and ready for communications. When in. Once read, the software must test the status of the 82C52
using a modem, an active state for this signal indicates that to see if any errors were detected in the data received. The
the modem is also connected to a communications line (is software must also look for status changes in the modem
on line). control lines.
2
Application Note 108
(A)
>1200bps
<1200bps
S0 S1 S2 S3 S4 S5 S6 S7 S8 S9 S10
START BIT
DETECTED HERE
3
Application Note 108
Assume that system X is configured to transmit and receive to be transmitted or received. The format of these characters
at 1200bps. The system we are communicating with is are made up of (1) a specific word length, (2) parity informa-
running slightly faster as stated above (1244bps). Our tion, and (3) a selected number of stop bits, used to indicate
sampling rate will still be based upon 1200bps, but the transmission of that character is completed.
sampling of the incoming signal will be off by a short time
period. With each sample this error accumulates. Thus, the D7 D6 D5 D4 D3 D2 D1 D0
skewing to the right becomes greater over time. By the time
STOP BIT 0 = 1 STOP BIT
we normally would be sampling the parity bit (S9), the stop SELECT 1 = 1.5 STOP BITS (TX) AND
bit(s) would be coming in over the SDI pin (see Figure 2A). 1 STOP BIT (RX) IF 5 DATA
In this case, the 82C52 thinks it is sampling the parity bit BITS SELECTED
when in fact, what it is seeing is really the stop bit. This could PARITY 000 = TX AND RX EVEN
CONTROL 001 = TX AND RX ODD
cause a parity error to be flagged. 010 = TX EVEN, RX ODD
011 = TX ODD, RX EVEN
Conversely, if data is being received at a baud rate slightly 100 = TX EVEN, RX CHECK
less than our specified baud rate, we would get a skewing of DISABLED
the received data in the opposite direction. From Figure 2C, 101 = TX ODD, RX CHECK
DISABLED
we see that at S10 we are checking the stop bit, but system 11X = GENERATION AND
Y is still transmitting the parity bit. Therefore, the Framing CHECK DISABLED
error will be flagged. WORD 00 = 5-BITS
LENGTH 01 = 6-BITS
1.11 Request To Send (RTS): SELECT 10 = 7-BITS
11 = 8-BITS
This signal is an output of the 82C52. It is used to inform a RESERVED SET TO 00 FOR FUTURE
modem or remote system that it wishes to transmit data. The PRODUCT UPGRADE
modem (remote system) would then respond by activating COMPATIBILITY
the CTS signal. As with the CTS, this signal is of most value FIGURE 3. UCR FORMAT
in half-duplex communications.
D0 – Stop Bit Select. This bit is used to select the number
of stop bits that the 82C52 will insert into a character to be
2.0 Control Registers transmitted, and the number to look for in received charac-
In order for the 82C52 to properly operate in a system, it ters. The stop bit(s) denote where the end of a character
must be configured for the desired form of operation. The occurs. The external device must be configured with the
user must decide how the device will be used in the system, same number of stop bits as the 82C52. The setting(s) for
and know the communications protocol of the device it will this bit are as follows:
be communicating with. For example, in a system communi- 0 – If this bit is set to zero, then a single stop bit will be gen-
cating with a modem we would need to utilize the modem erated and checked for.
control lines. When using the 82C52 in a local area network
these modem control lines may be of no use to us. 1 – Setting this bit to a one will cause either of two configura-
tions. If we select a character length of 5 data bits, the
The 82C52 is initialized and configured by writing a series of 82C52 will generate 1.5 stop bits during transmission,
control words from the CPU to various control registers in and will look for a single stop bit when receiving data. If a
the device. These registers include the UART Control Regis- character length of 6, 7, or 8 data bits is selected, then
ter (UCR), the Baud Rate Selector Register(BRSR), and the two (2) stop bits will be generated and checked for.
Modem Control Register (MCR).
D3, D2 and D1 – Parity Control. These three bits are used
UCR: Defines the format of characters being transmitted. to control the generation and checking of the parity bit. The
The format of the characters includes the number of 82C52 can be configured to perform this function one of
data bits, parity control, and the number of stop bits. seven ways. These are:
BRSR: Used in setting up the internal baud rate generator in 000 – Even parity is generated for transmitting data, and
the 82C52 for a specific baud rate. It will also be will be checked for when receiving data.
used to specify what the CO output is to be.
001 – Odd parity is generated for transmitting data, and
MCR: Defines which interrupts will be enabled, and will also checked for during data reception.
set the modem control output lines (RTS and DTR).
In addition, the MCR allows the user to select one of 010 – Even parity is generated for data transmission, and
four modes of communications (normal mode, echo odd parity will be checked for during data reception.
mode, transmit break, and loop test mode).
011 – Odd parity is generated for data transmission, and
2.1 UART Control Register even parity will be checked for during data reception.
The UART Control Register (UCR) is a write-only register. 100 –Even parity is generated for data transmission, how-
Writing a command word to the UCR configures the trans- ever, the 82C52 will do no parity checking on data that has
mission and reception circuitry of the 82C52. The command been received.
word essentially describes the format of characters that are
4
Application Note 108
101 – Odd parity is generated for data transmission. The The 16X clock speed can be output to the CO pin of the
82C52 will not check parity on data received. device through the CO Select function of the BRSR. If CO
select is not selected, the output of the CO pin will reflect the
11X – The generation of a parity bit is disabled. Also, the
crystal frequency input by the part on the IX pin. Note, this
82C52 will not check for parity on incoming data. D1
output (CO) is a buffered version of the IX input or 16X baud
is not used therefore, it can be either a 0 or a 1.
rate.
TABLE 1. PARITY SELECTION
D7 D6 D5 D4 D3 D2 D1 D0
TRANSMITTER RECEIVER
0 1 6-Bits
FIGURE 4. BRSR FORMAT
1 0 7-Bits
D1 and D0 – Prescaler Select. This allows the user to
1 1 8-Bits
choose one of four values that the input clock frequency (IX)
will be divided by.
D7, D6 – Reserved. These bits have been reserved for TABLE 3. PRESCALER SELECTION
future product upgrade compatibility. To insure that the future
upgrades of the 82C52 will operate with existing software, PRESCALER
D1 D0 DIVISOR
these bits must both be set to zero (00).
2.2 Baud Rate Select Register 0 0 ÷1
5
Application Note 108
D6, D5, D4, D3, and D2 – Divisor Select. The state of these NOTE: All baud rates are exact except for:
bits determines the value of the Divisor select. The possible
values are as follows in Table 4: TABLE 6. PERCENT DIFFERENTIAL
6
Application Note 108
7
Application Note 108
8
Application Note 108
Also, should both the MIEN and INTEN bits be set in the A change in any of the status bits will cause an interrupt if
MCR register, an interrupt will be generated when the MS bit the INTEN and MIEN bits of the MCR are enabled.
gets set.
D7 D6 D5 D4 D3 D2 D1 D0
0 – No status change.
1 – Status change detected. CLEAR TO SEND (CTS) 0 = FALSE
1 = TRUE
D5 – Transmission Complete (TC). When a character is
DATA SET READY (DSR) 0 = FALSE
written to the 82C52 Transmitter Buffer Register (TBR), it will 1 = TRUE
be transferred to the Transmitter Register before actually
being shifted out serially through the SDO pin. When the 0
9
Application Note 108
D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
= 31H
0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 1
Bits D7 and D6 are automatically zeroed out by the 82C52. The two most significant bits are zeroed out automatically by
the 82C52.
D7 D6 D5 D4 D3 D2 D1 D0 D7 D6 D5 D4 D3 D2 D1 D0
BIT 0 BIT 0
BIT 1 BIT 1
5-BIT 5-BIT
BIT 2 6-BIT BIT 2 6-BIT
WORD WORD
WORD 7-BIT WORD 7-BIT
BIT 3 8-BIT BIT 3 8-BIT
WORD WORD
BIT 4 WORD BIT 4 WORD
BIT 5 BIT 5
BIT 6 BIT 6
BIT 7 BIT 7
NOTE: THE LSB, BIT 0 IS THE FIRST SERIAL DATA BIT RECEIVED NOTE: THE LSB, BIT 0 IS THE FIRST SERIAL DATA BIT TRANSMITTED
The Transmit Buffer Register is also 8-bits wide. Because we When addressing I/O, we would use either the IN instruction
can specify data lengths as being from 5 to 8-bits wide, the or the OUT instruction. The port address specified in the
82C52 right justifies the data when it is written to the TBR, instruction is placed on the address bus, and the IO/M signal
and fills the unused bits with zero’s. In other words, unused selects and activates the control logic for I/O. If we used one
(most significant) bits are truncated. For example, if we set of the memory commands (MOV, CMP, TEST, etc.), the IO/M
up the device so that 6 data bits are specified and we write signal would activate the control logic for the system
the character 71H (01110001 b) to the TBR, we will memory.
effectively be transmitting the character:
All Intersil U.S. products are manufactured, assembled and tested utilizing ISO9000 quality systems.
Intersil Corporation’s quality certifications can be viewed at www.intersil.com/design/quality
Intersil products are sold by description only. Intersil Corporation reserves the right to make changes in circuit design, software and/or specifications at any time without
notice. Accordingly, the reader is cautioned to verify that data sheets are current before placing orders. Information furnished by Intersil is believed to be accurate and
reliable. However, no responsibility is assumed by Intersil or its subsidiaries for its use; nor for any infringements of patents or other rights of third parties which may result
from its use. No license is granted by implication or otherwise under any patent or patent rights of Intersil or its subsidiaries.
For information regarding Intersil Corporation and its products, see www.intersil.com
10
Application Note 108
I/O
6.0 Reset Of The 82C52
There are two distinct ways in which the 82C52 can be reset
MEMORY to a known initial state: (1) By applying a reset pulse for at
1024K* least two clock cycles on the RST pin, or (2) through soft-
ware.
* ~ IN 80C86 SYSTEM
A hardware reset is accomplished by forcing the RST pin to
FIGURE 14. MEMORY MAPPED I/O ADDRESSING a high state for a minimum of two clock cycles. This should
be for two cycles of the 82C52’s IX clock input as opposed to
11
Application Note 108
the system clock. This reset will cause the UART Status Addressing of the internal registers on the 82C52 occurs by
Register (USR) to be set to 60H (TC and TBRE bits will be using the address lines A1 and A0, as well as the WR and
set), and the Modem Control Register(MCR) will be cleared. RD lines. A more complete description of this is shown in
Any lines associated with the bits in the USR and MCR will Table 8.
be cleared or disabled.
82C52 Polling Operation
During the reset of the device, the Baud Rate Select Regis-
When utilizing a polling scheme for communications with the
ter (BRSR) and the UART Control Register (UCR) will not be
82C52, it is important to note that the UART status register
affected. However, if the reset comes due to power on, these
will be cleared of its contents when it is read by the proces-
registers will have an indeterminate value associated with
sor. Therefore, subsequent reads of this register will show
them. After this reset, the 82C52 will remain in an idle state
the contents to be 00H unless the status of the device has
until programmed to its desired configuration.
changed between reads. Because of this, it would be neces-
A second method of resetting the 82C52 is through a soft- sary for a copy of the status to be saved so that the proper
ware reset. This will allow the device to be set to a known status can be seen.
state. The procedure for performing a software reset is out-
Interrupt Driven Operation
lined below:
(1) MCR = 00H. Write a zero to the MCR. This will disable In this example, the 82C59A Interrupt Controller is being
the receiver as well as the modem control lines, and used to handle interrupts generated by the 82C52. The
interrupts. 82C59A then communicates this interrupt information to the
CPU so that it may be properly serviced. An example of how
(2) Read the RBR to clear out any residual data.
the 82C59A and 82C52 are interfaced to the CPU is shown
(3) Read the USR to reset status, thus keeping status lines in Figure 15.
from causing possible interrupts to the CPU.
(4) Reconfigure the device for the desired mode of opera-
tion. AD0 A0 D0 -D7
AD2 A Y6 CS
7.0 Programming The 82C52 IR2
AD3 B Y4
In order to configure the 82C52 for proper operation, three AD4 C 82C59A
separate command words need to be written to the com-
mand (control) registers that were specified earlier. 74XX138 CS
INTR
These registers include (1) the UART Control Register, (2) AD0 A0
the Baud Rate Select Register, and (3) the Modem Control AD1 A0
Register. When programming the device, these registers can
be written to in any order. It is advisable to initialize the D0 -D7
Modem Control Register last because it controls the 82C52
enabling of interrupts, and the receiver circuitry. Once initial-
ized, the 82C52 can be reconfigured at any time by writing
new command word(s) to the control registers. However, the 80C88 80C88
ADDRESS BUS DATA BUS
device should not be actively transmitting or receiving data
when reconfiguring the control registers. FIGURE 15. INTERRUPT DRIVEN SYSTEM
12