UART Controller 21 2014.08.18
Total Page:16
File Type:pdf, Size:1020Kb
UART Controller 21 2014.08.18 a10_54021 Subscribe Send Feedback The hard processor system (HPS) provides two UART controllers for asynchronous serial communication. The UART controllers are based on an industry standard 16550 UART controller. The UART controllers are instances of the Synopsys® DesignWare® APB Universal Asynchronous Receiver/Transmitter (DW_apb_uart) peripheral.(1) UART Controller Features The UART controller provides the following functionality and features: • Programmable character properties, such as number of data bits per character, optional parity bits, and number of stop bits † • Line break generation and detection † • DMA controller handshaking interface • Prioritized interrupt identification † • Programmable baud rate • False start bit detection † • Automatic flow control mode per 16750 standard † • Internal loopback mode support • 128-byte transmit and receive FIFO buffers • FIFO buffer status registers † • FIFO buffer access mode (for FIFO buffer testing) enables write of receive FIFO buffer by master and read of transmit FIFO buffer by master † • Shadow registers reduce software overhead and provide programmable reset † • Transmitter holding register empty (THRE) interrupt mode † • Separate thresholds for DMA request and handshake signals to maximize throughput (1) Portions © 2014 Synopsys, Inc. Used with permission. All rights reserved. Synopsys & DesignWare are registered trademarks of Synopsys, Inc. All documentation is provided "as is" and without any warranty. Synopsys expressly disclaims any and all warranties, express, implied, or otherwise, including the implied warranties of merchantability, fitness for a particular purpose, and non-infringement, and any warranties arising out of a course of dealing or usage of trade. †Paragraphs marked with the dagger (†) symbol are Synopsys Proprietary. Used with permission. © 2014 Altera Corporation. All rights reserved. ALTERA, ARRIA, CYCLONE, ENPIRION, MAX, MEGACORE, NIOS, QUARTUS and STRATIX words and logos are trademarks of Altera Corporation and registered in the U.S. Patent and Trademark Office and in other countries. All other words and logos identified as trademarks or service marks are the property of their respective holders as described at ISO www.altera.com/common/legal.html. Altera warrants performance of its semiconductor products to current specifications in accordance with 9001:2008 Altera's standard warranty, but reserves the right to make changes to any products and services at any time without notice. Altera assumes Registered no responsibility or liability arising out of the application or use of any information, product, or service described herein except as expressly agreed to in writing by Altera. Altera customers are advised to obtain the latest version of device specifications before relying on any published information and before placing orders for products or services. www.altera.com 101 Innovation Drive, San Jose, CA 95134 a10_54021 21-2 UART Controller Block Diagram and System Integration 2014.08.18 UART Controller Block Diagram and System Integration Figure 21-1: UART Block Diagram UART Controller Serial Transmitter/ Interrupt and System MPU Receiver Reset Control IRQ Baud Clock To I/O FIFO Buffer Pins RX Generator DMA TX DMA Controller RTS Interface CTS Clock Register Block Manager Reset Slave Interface Manager L4 Peripheral Bus Table 21-1: UART Controller Block Descriptions Block Description Slave interface Slave interface between the component and L4 peripheral bus. Register block Provides main UART control, status, and interrupt generation functions.† FIFO buffer Provides FIFO buffer control and storage. † Baud clock generator Generates the transmitter and receiver baud clock. With a reference clock of 100 MHz, the UART controller supports transfer rates of 95 baud to 6.25 Mbaud. This supports communication with all known 16550 devices. The baud rate is controlled by programming the interrupt enable or divisor latch high (IER_DLH) and receive buffer, transmit holding, or divisor latch low (RBR_THR_DLL) registers. Serial transmitter Converts parallel data written to the UART into serial data and adds all additional bits, as specified by the control register, for transmission. This makeup of serial data, referred to as a character, exits the block in serial UART. † Serial receiver Converts the serial data character (as specified by the control register) received in the UART format to parallel form. Parity error detection, framing error detection and line break detection is carried out in this block. † Altera Corporation UART Controller Send Feedback a10_54021 2014.08.18 Functional Description of the UART Controller 21-3 Block Description DMA interface The UART controller includes a DMA controller interface to indicate when received data is available or when the transmit FIFO buffer requires data. The DMA requires two channels, one for transmit and one for receive. The UART controller supports single and burst transfers. You can use DMA in FIFO buffer and non-FIFO buffer mode. Related Information DMA Controller For more information, refer to the DMA Controller chapter in the Hard Processor System Technical Reference Manual. Functional Description of the UART Controller The HPS UART is based on an industry-standard 16550 UART. The UART supports serial communication with a peripheral, modem (data carrier equipment), or data set. The master (CPU) writes data over the slave bus to the UART. The UART converts the data to serial format and transmits to the destination device. The UART also receives serial data and stores it for the master (CPU). † The UART’s registers control the character length, baud rate, parity generation and checking, and interrupt generation. The UART’s single interrupt output signal is supported by several prioritized interrupt types that trigger assertion. You can separately enable or disable each of the interrupt types with the control registers. † FIFO Buffer Support The UART controller includes 128-byte FIFO buffers to buffer transmit and receive data. FIFO buffer access mode allows the master to write the receive FIFO buffer and to read the transmit FIFO buffer for test purposes. FIFO buffer access mode is enabled with the FIFO access register (FAR). Once enabled, the control portions of the transmit and receive FIFO buffers are reset and the FIFO buffers are treated as empty. † When FIFO buffer access mode is enabled, you can write data to the transmit FIFO buffer as normal; however, no serial transmission occurs in this mode and no data leaves the FIFO buffer. You can read back the data that is written to the transmit FIFO buffer with the transmit FIFO read (TFR) register. The TFR register provides the current data at the top of the transmit FIFO buffer. † Similarly, you can also read data from the receive FIFO buffer in FIFO buffer access mode. Since the normal operation of the UART is halted in this mode, you must write data to the receive FIFO buffer to read it back. The receive FIFO write (RFW) register writes data to the receive FIFO buffer. The upper two bits of the 10- bit register write framing errors and parity error detection information to the receive FIFO buffer. Bit 9 of RFW indicates a framing error and bit 8 of RFW indicates a parity error. Although you cannot read these bits back from the receive buffer register, you can check the bits by reading the line status register (LSR), and by checking the corresponding bits when the data in question is at the top of the receive FIFO buffer. † UART(RS232) Serial Protocol Because the serial communication between the UART controller and the selected device is asynchronous, additional bits (start and stop) are added to the serial data to indicate the beginning and end. Utilizing these bits allows two devices to be synchronized. This structure of serial data accompanied by start and stop bits is referred to as a character, as shown in below.† UART Controller Altera Corporation Send Feedback a10_54021 21-4 Automatic Flow Control 2014.08.18 Figure 21-2: Serial Data Format Bit Time Serial Data Start Data Bits 5 - 8 Parity Stop Bits 1, 1.5, 2 One Character An additional parity bit may be added to the serial character. This bit appears after the last data bit and before the stop bit(s) in the character structure to provide the UART controller with the ability to perform simple error checking on the received data.† The Control Register is used to control the serial character characteristics. The individual bits of the data word are sent after the start bit, starting with the least- significant bit (LSB). These are followed by the optional parity bit, followed by the stop bit(s), which can be 1, 1.5 or 2.† All the bits in the transmission (with exception to the half stop bit when 1.5 stop bits are used) are transmitted for exactly the same time duration. This is referred to as a Bit Period or Bit Time. One Bit Time equals 16 baud clocks. To ensure stability on the line, the receiver samples the serial input data at approximately the midpoint of the Bit Time once the start bit has been detected. Because the exact number of baud clocks that each bit transmission is known, calculating the midpoint for sampling is not difficult. That is, every 16 baud clocks after the midpoint sample of the start bit.† Together with serial input debouncing, this feature also contributes to avoid the detection of false start bits. Short glitches are filtered out by debouncing, and no transition is detected on the line. If a glitch is wide enough to avoid filtering by debouncing, a falling edge is detected. However, a start bit is detected only if the line is sampled low again after half a bit time has elapsed. † Figure 21-3: Receiver Serial Data Sample Points Serial Data In Start Data Bit 0 (LSB) Data Bit 1 8 16 16 The baud rate of the UART controller is controlled by the serial clock and the Divisor Latch Register ( DLH and DLL ).† Automatic Flow Control The UART includes 16750-compatible request-to-send (RTS) and clear-to-send (CTS) serial data automatic flow control mode.