Professional Documents
Culture Documents
NOTICE: This pre-release document contains confidential and proprietary information of Xilinx, Inc. and is being disclosed to
you as a participant in an early access program, under obligation of confidentiality. You may print one (1) copy of this
document for evaluation purposes. You may not modify, distribute, or disclose this material to anyone, including your
employees, coworkers, or contractors (these individuals must apply for separate access to the program). This document
contains preliminary information and is subject to change without notice. Information provided herein relates to products
and/or services not yet available for sale, and provided solely for information purposes and are not intended, or to be
construed, as an offer for sale or an attempted commercialization of the products and/or services referred to herein.
DMAC
ARM AMBA DMA Controller DMA-330, ARM part DDI 0424C (ID080710)
Copyright 2007, 2009-2010 ARM Limited, All rights reserved.
SDT
TTC
USB
GEM
SDIO
I2C
SPI
UART
DMC
SMC
Chapter 19
UART Controller
19 UART
19.1 Introduction
The UART module is a full-duplex asynchronous receiver and transmitter that supports a wide range of
software programmable baud rates and data formats. It can also accommodate for automatic parity
generation and several error detection schemes and provides both receive and transmit FIFO buffering for
the APU.
The UART peripheral is structured into separate receiver and transmitter data paths, which include 64-byte
FIFOs. The rate of operation of these data paths is controlled by the Baud Rate Generator module.
The mode of operation is configured using the Control Logic module, and the current status of the UART is
indicated via the Interrupt Control module. The current mode is also used to control the Mode Switch
module which selects the various loopback modes available.
Data to be transmitted is written from the APU into the Transmitter FIFO using byte operations through the
APB interface.
When the Transmitter FIFO contains enough data to transmit, the Transmitter module pulls the data from
the FIFO and serializes it onto the transmitter serial output.
Data received is deserialized by the Receiver module and written into the Receiver FIFO. The fill level of
the Receiver FIFO module is then used to trigger an interrupt to the APU. The APU pulls data from the
Receiver FIFO by reading byte or double bytes using the APB interface.
If the UART is being used in a modem-like application, the Modem Control module detects and generates
the modem handshake signals appropriately and also controls the receiver and transmitter paths according
to the handshaking protocol.
19.1.1
Features
The PS supports two UART devices in the IOP with these key features:
6, 7, or 8 data bits
Interrupts generation
19.1.2
System Viewpoint
The system viewpoint diagram for the UART module is shown in Figure 1.
MIO EMIO
Routing
Slave
ports
CPU_1x clock
UART{0, 1}_CPU1X_RST
Control
and Status
Registers
UART{0, 1}_REF_RST
N, N
CD TS
,D ,R
SN RN
CT DT
,
x,
, R RIN
Tx N,
R
APB
Tx, Rx
MIO
Pins
DS
PS Master
Interconnect
UART
Interface
Controller
EMIO
Signals
PL
Fabric
UART{0, 1}_REF_CLK
There are two UARTs in the PS. Each UART can be configured independently. The TX and RX interface
can be mapped to either the EMIO interface or the GPIO interface. The Modem control signals are only
available through the EMIO interface. The clocks and resets to the UART are sourced from the global
clock and reset blocks for the PS. The APB interface is connected to an AMBA interconnect which allows
multiple masters to have access to the
Software-driven modem flow control signals can be implemented via the GPIO controller and route the IO
signals to either the MIO or EMIO.
19.2
19.2.1
Functional Description
Block Diagram
Transmitter
FIFO
APB
APB
Interface
Interrupts
Transmitter
Transmit
Mode
Switch
Baud Rate
Generator
Control
Logic
Interrupt
Control
Receive
Receiver
FIFO
Receiver
Modem
Control
Control
19.2.2
The UART APB module implements a standard AMBA 2.0 APB slave interface. This allows an external
APB master to read and write to the defined UART registers, which are distributed throughout the other
UART modules.
19.2.3
Control Logic
The Control Logic module contains the Control register and the Mode register, which are used to select
the various operating modes of the UART.
The Control register enables, disables, and issues soft resets to the Receiver and Transmitter modules. In
addition, it restarts the receiver timeout period, and controls the transmitter break logic.
The Mode register selects the clock used by the baud rate generator. It also selects the bit length, parity bit
and stop bit to be used by transmitted and received data. In addition, it selects the mode of operation of the
UART, switching between normal UART mode, automatic echo, local loopback, or remote loopback as
required.
19.2.4
The baud rate generator furnishes the bit period clock, or baud rate clock, for both the receiver and the
transmitter. The baud rate clock is implemented by distributing the base clock uart_clk and a single
cycle clock enable to achieve the effect of clocking at the appropriate frequency division.
The effective logic for the baud rate generation is shown in Figure 3.
CLKS
uart_clk
sel_clk
Divide
by 8
uart_clk8
baud_sample
Divide by CD
CC > 1
1
CC = 1
Divide
by
(BDIV + 1)
baud_tx_rate
baud_rx_rate
CC = 0
The baud rate generator uses the master clock signal, uart_ref_clk.
The uart_ref_clk clock is divided down to provide three further clocks enable pulses, baud_sample,
baud_tx_rate and baud_rx_rate. The baud_tx_rate is the target baud rate used for
transmitting data. The baud_rx_rate is nominally at the same rate, but gets resynchronised to the
incoming received data. The baud_sample runs at a multiple of baud_rx_rate and
baud_tx_rate and is used to oversample the received data.
First, uart_ref_clk is divided by the CD field value in the Baud Rate Generator register to generate
the baud_sample clock enable. This register may be programmed with a value between 1 and 65535,
and its reset value may be defined at compile time.
Secondly, the baud_sample clock is divided by BDIV plus 1. BDIV is a programmable field in the
Baud Rate Divider register and may be programmed with a value between 0 and 255. It has a reset value
of 15, inferring a default ratio of 16 baud_sample clocks per baud_tx_clock / baud_rx_rate.
Thus the frequency of the baud_sample clock enable is shown in Equation (1).
Equation (1)
The frequency of the baud_rx_rate and baud_tx_rate clock enables is show in Equation (2).
Equation (2)
It is essential to disable the transmitter and receiver before writing to the baud rate generator register,
ua_brgr, or the baud rate divider register, ua_div. Issue a soft reset to both the transmitter and
receiver before they are re-enabled.
Some examples of the relationship between the uart_ref_clk clock, baud rate, clock divisor, and the rate of
error are shown in Table 1. The highlighted entry shows the default reset values for CD and BDIV. For
Clock
Uart_ref_clk
Calcd
CD
Actual
CD
BDIV
Actual
Baud Rate
Error
(BPS)
% Error
600
1354.167
1354
15
600.074
0.074
0.012
9600
13.021
13
12
9615.385
15.385
0.160
Uart_ref_clk
9600
84.635
85
15
9558.823
-41.176
-0.429
Uart_ref_clk
28800
41.035
41
10
28824.834
-24.834
-0.086
230400
1.008
232142.875
-1742.857
-0.756
Uart_ref_clk/8
Uart_ref_clk/8
Notes:
1.
2.
19.2.5
Transmitter FIFO
The transmitter FIFO stores data written from the APB Interface until it is popped out by the Transmitter
module and loaded into its shift register. The FIFO size is 8 bits maximum data width.
Data is loaded into the transmitter FIFO by writing to the Transmit FIFO register.
When data is loaded into the FIFO, the transmit FIFO empty flag is cleared and remains in this low state
until the last word in the FIFO has been popped out and loaded into the transmitter shift register. This
means that the host SW has another full serial word time until the next data is needed, allowing it to react to
the empty flag being set and write another word in the FIFO without loss in transmission time.
The transmit FIFO full flag indicates that the FIFO is completely full and prevents any further data from
being loaded into the FIFO. If another APB write to the FIFO is performed an overflow will be triggered
and the write data will not be loaded into the FIFO.
The transmit FIFO nearly-full flag indicates that there is only byte free in the FIFO and writing one more
byte.
A threshold trigger can be setup on the transmitter FIFO fill level. The Transmitter Trigger register may be
used to setup this value, such that the trigger is set when the FIFO fill level reaches this programmed value.
19.2.6
Transmitter
The Transmitter module pops parallel data from the Transmitter FIFO and loads it into the transmitter
shift register so that it can be serialised.
The transmitter shifts out the start bit, data bits, parity bit, and stop bits as a serial data stream. Data is
transmitted, least significant bit first, on the falling edge of the transmit baud clock enable,
baud_tx_rate. A typical transmitted data stream is illustrated in Figure 4.
baud_tx_rate
TXD
D1
D2
D3
D4
D5
D6
D7
D8
PA
19.2.8
Receiver
The UART continuously over-samples the ua_rxd signal using uart_clk and the clock enable,
baud_sample. When the samples detect a transition to a low level, it may indicate the beginning of a
start bit. When the UART senses a low level at the ua_rxd input, it waits for a count of half of BDIV
baud rate clock cycles and then samples three more times. If all three bits still indicate a low level, the
receiver considers this to be a valid start bit, as illustrated in Figure 5 for the default BDIV of 15.
When a valid start bit is identified, the receiver baud rate clock enable, baud_rx_rate, is
resynchronised so that further sampling of the incoming ua_rxd happens around the theoretical midpoint of each bit, as illustrated in Figure 6.
When the resynchronised baud_rx_rate is high, the last three sampled bits are compared. The logic
value is determined by majority voting, two samples having the same value define the value of the data
19.2.9
Mode Switch
The mode switch module provides an interface between the external transmit and receive signals, and the
rest of the UART. This block is used to implement the mode selected by the Mode register: normal mode,
automatic echo, local loopback or remote loopback. For details, refer to Modes of Operation.
10
19.3.1
Clock Modes
The UART baud rate is derived from the uart_ref_clk provided by the clock controller.
See Chapter 25, Clocks for details on system clock generation.
19.3.2
The Mode register can be programmed to control the UART serial bit frame format, including using frame
formats of 6, 7 or 8 databits, generating or checking even, odd, space, mark, or no parity. For each bit
frame format, 1, 1.5 or 2 stop bits can be used, as shown in Figure 7.
19.3.3
Operational Modes
The CHMODE field in the Mode register can be programmed to use one of the four operating modes of the
UART; Normal, Automatic Echo, Local Loopback and Remote Loopback. Each of the operating modes
is described in the following sections.
11
uart_tx
Transmitter
Device Core
UART
UART
Mode Switch
Receiver
Pins
uart_rx
Automatic Echo
In this mode the receiver data input is immediately transmitted through the transmitter output pin. No
internal data can be transmitted from the UART but received data can be read by the processor.
Local Loopback
In this mode the signal transmitted from the UART is connected to the receiver input. No data can be
transmitted and no external data can be received.
12
Remote Loopback
In this mode the receiver input data is immediately transmitted through the transmitter output pin,
ua_txd. No internal data can be transmitted from the UART and the UART cannot access received data.
13
Register Names
Overview
Configuration
Control_reg
Mode_reg
Baud_rate_reg_reg
Baud_rate_divider_reg
Channel_sts_reg
Interrupt processing
Intrpt_en_reg
Intrpt_dis_reg
Intrpt_mask_reg
Chnl_int_sts_reg
Receiver
Rcvr_timeout_reg
Rcvr_FIFO_trigger_reg
Transmitter
Tx_FIFO_trigger_reg
Modem
Modem_ctrl_reg
Modem_sts_reg
Data
TX_RX_FIFO
14
Table 3 shows the interface signals for UART0. For UART1, simply substitute the uart0 portion of each
signal name with uart1.
Table 3: UART0 interface for RS232 Protocol
Signal Name
I/O
UART Pin
uart0_rx
uart0_tx
19.5.2
Description
Table 4 shows the pins for UART0. For UART1, simply substitute the UART0 portion of each pin name
with UART1.
Table 4: UART Pin List Details
Pin Name
Dir
Name
Description
EMIOUART0TX
EMIO_UART0_TX
EMIOUART0RX
EMIO_UART0_RX
EMIOUART0CTSN
EMIO_UART0_CTSN
EMIOUART0RTSN
EMIO_UART0_RTSN
EMIOUART0DSRN
EMIO_UART0_DSRN
EMIOUART0DCDN
EMIO_UART0_DCDN
EMIOUART0RIN
EMIO_UART0_RIN
EMIOUART0DTRN
EMIO_UART0_DTRN
15