Universal Asynchronous Receiver Transmitter (UART)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 38

Serial Communication Interfaces

- UART (RS232) , RS485

T.REVATHI
TIFAC CORE IN AUTOMOTIVE INFOTRONICS
VIT UNIVERSITY, VELLORE

Contents
Basic Concepts of Serial communication
Types
Advantages
Applications
UART Features in ARM

Implementation Steps Transmitter & Receiver

Need of Serial Communication


Low Pin counts.
Supporting high data rate compared to IO lines.
Communication can be performed with just one IO

pin rather than to use multiple pins when compared


with Parallel Communication.
Data Synchronization.

Serial Communication
Serial Communication Data Bits will be sent in a serial

way over a single line.


Asynchronous data transfer utilizes EIA-232 (Electronics

Industry Association) Standard.


Serial communication is often used either to control or to

receive data from an embedded microprocessor.

Advantages of Serial Communication


Transmission distance is more.
Cable connection is simpler.
Low Cost in implementation.

Types of Serial communication


Asynchronous serial communication

Universal Asynchronous Receiver Transmitter (UART)

Synchronous serial communication

Serial Peripheral Interface (SPI)

Inter Integrated Circuit (I2C)

Terms to be remembered
Baud Rate No. of bits transmitted over the serial link per

second. (Also a measurement of

transmission speed in

Asynchronous communication)
Half-duplex

Communication

channel

where

both

transmission and reception are possible, but only in one

direction at a time
Full-duplex - Connection permits the sending and receiving

of data at the same time

Data Communication System


Devices that uses serial cables for their communication are

split into two categories

Data Terminal Equipment

Data Communication Equipment

Asynchronous Data Transfer


Allows data to be transmitted without the sender has to send a clock

signal to the receiver.


Special bits will be added to each word in order to synchronize the

sending and receiving of the data.


When a word is given to the UART for Asynchronous transmissions, a

bit called the "Start Bit" is added to the beginning of each word that is
to be transmitted.

Asynchronous Data Transfer


When the entire data word has been sent, the transmitter

may add a Parity Bit that the transmitter generates.


Then at least one Stop Bit is sent by the transmitter.
If the Stop Bit does not appear when it is supposed to, the

UART considers the entire word to be garbled and will


report a Framing Error.

Data Format Signal levels


Data is transmitted character by character bit serially
A Character consists of
One start bit (0)
7 8 data bits
An optional parity bit
One or one and a half or two stop bits (1)

Least significant bit is transmitted first


Most Significant bit is transmitted last

Need of level conversion


All the microcontroller signals are indicated only by the positive signals of

5V TTL /15VCMOS logic.


If the signal is transmitted to a distance, may be at the end of a long cable,

by the time the signal reaches the receiver, its voltage may have attenuated
by the cable impedance or have noise riding on it.
In order to avoid and decrease the noise margin, the signal from the

microcontroller has to be converted to a level called Recommended


Standard 232 (RS-232) signal for point to point communication.

RS 232 Electrical Specification


Signal Rate < 20 kbps.
The signal can transfer correctly within 15 meters.
The receiver input voltage range is -25 V to +25 V.
The receiver output is high when input is open circuit.
A voltage more negative than -3 V at the receiver input is

interpreted as a logic 1.
A voltage more positive than +3 V at the receiver input is

interpreted as a logic 0.

Max232 Level conversion circuit

RS 232 Level Conversion

Types of Connectors

Typical Connection

Applications

Dial-up modems

GPS receivers

Bar code scanners

Industrial field buses

LED and LCD text displays

Printers

Satellite Phones

Computer terminal

Test and measuring equipment


such as digital multi meters and
weighing systems

Updating Firmware on various


consumer devices.

Serial mouse

RS 485 Specifications
RS485 is a balanced line, Half-duplex transmission system allowing

transmission distances of up to 1.2 km.

RS-485 Balanced Differential Bus

RS-485 Signaling
For Input
If a logic high is received on the

For Output
If Line A is more positive than line

input of the transmitter (DI = 1),

B (VIA VIB > 200 mV) on the

Line A is more positive than Line B

input of the receiver, the receiver

(VOA > VOB) on the driver output.

output is a logic high (RO = 1).

If a logic low is received on the

If Line B is more positive than Line

input of the transmitter (DI = 0),

A (VIB VIA > 200 mV) on the

the transmitter causes Line B to be

input of the receiver, the receiver

more positive than Line A (VOB >

output is a logic low (RO = 0).

VOA).

RS 485 Network Topologies

Rs-485 Driver IC SN75176


Voltage produced by the driver appears across a

pair of signal wires that transmit only one


signal. Both wires are driven opposite.
RS-485 driver has always the Enable direction

control signal.
Differential system provides noise immunity,

because much of the common mode signal can


be rejected by the receiver. So ground shifts and
induced noise signals can be nullified.

RS 485 Half Duplex Network

Half-duplex RS-485 links have multiple drivers and receivers on the same signal path.

This is the reason why RS-485 transceivers must have driver/receiver enable pins enabling only
one driver to send data at a time.

Advantages of RS-485
Long distance linksup to 4000 feet.

Bidirectional communications possible over a single pair of twisted

cables.
Differential transmission increases noise immunity and decreases noise

emissions.
Multiple drivers and receivers can be connected on the same bus.
Wide common-mode range allows for differences in ground potential

between the driver and receiver.


TIA/EIA-485-A allow for data rates of up to 10 Mbps.

Applications of RS-485
Motor Control
Industrial Automation
Battery powered applications
Tele-communications equipment
Industrial Process Control

Comparison between various serial standards

Features in LM4F120H5QR

UART in LM4F120H5QR
Programmable baud-rate generator allowing speeds up to 5 Mbps for regular speed (divide by
16) and 10 Mbps for high speed (divide by 8)
Separate 16x8 transmit (TX) and receive (RX) FIFOs to reduce CPU interrupt service loading
Programmable FIFO length, including 1-byte deep operation providing conventional

double-buffered interface
FIFO trigger levels of 1/8, 1/4, 1/2, 3/4, and 7/8
Standard asynchronous communication bits for start, stop, and parity
Line-break generation and detection
Fully programmable serial interface characteristics

5, 6, 7, or 8 data bits
Even, odd, stick, or no-parity bit generation/detection
1 or 2 stop bit generation

Block Diagram

UART Signal Mapping

Programming Procedure Stellarisware Implementation


Step 1: Set the clock source

Step 2: Select / Enable the peripheral


Step 3: Select the Port corresponds to the peripheral function
Step 4: Select the UART function for the respective pin
Step 5: Enable the Port corresponds to the peripheral function
Step 6: Configure the Baud rate, No. of Data bits & Parity
Step 7 : Start Transmission / Reception of Data

SysCtlClockSet

Sets the clocking of the device.

Step 1: Set the clock


source

Prototype:

void SysCtlClockSet(unsigned long ulConfig)

Parameters:

ulConfig is the required configuration of the device clocking.

Description:

This function configures the clocking of the device. The input crystal
frequency, oscillator to be used, use of the PLL, and the system clock

divider are all configured with this function.

SysCtlPeripheralEnable

Enables a peripheral.

Prototype:

Step 2: Select / Enable


the peripheral

void SysCtlPeripheralEnable(unsigned long ulPeripheral)

Parameters:

ulPeripheral is the peripheral to enable.

Description:

Step 3: Enable the Port

corresponds to the peripheral


function

Peripherals are enabled with this function. At power-up, all


peripherals are disabled; they must be enabled in order to operate or
respond to register reads/writes.

GPIOPinTypeUART
Step 4: Select the UART

Configures pin(s) for use by the UART peripheral.

function for the respective pin

Prototype:

void GPIOPinTypeUART(unsigned long ulPort, unsigned char ucPins)

Parameters:

ulPort is the base address of the GPIO port.

ucPins is the bit-packed representation of the pin(s).

Step 5: Enable the Port

corresponds to the
peripheral function

Description:

The UART pins must be properly configured for the UART peripheral to function correctly. This
function provides a typical configuration for those pin(s);

The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to be
accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO port pin 1,

and so on.
This function cannot be used to turn any pin into a UART pin; it only configures a UART pin for proper

operation.

UARTConfigSetExpClk

Sets the configuration of a UART.

Prototype:

Step 6: Configure the Baud


rate, No. of Data bits & Parity

void UARTConfigSetExpClk(unsigned long ulBase,


unsigned long ulUARTClk,
unsigned long ulBaud,

unsigned long ulConfig)

Parameters:

ulBase is the base address of the UART port.


ulUARTClk is the rate of the clock supplied to the UART module.
ulBaud is the desired baud rate.
ulConfig is the data format for the port (number of data bits, number of stop
bits, and parity).

To Transmit Data - UARTCharPut

Waits to send a character from the specified port.

Prototype:

void UARTCharPut(unsigned long ulBase,unsigned char ucData)

Parameters:

ulBase is the base address of the UART port.

ucData is the character to be transmitted.

Transmitter

Description:

This function sends the character ucData to the transmit FIFO for
the specified port. If there is no space available in the transmit FIFO,

this function waits until there is space available before returning.

To Receive Data - UARTCharGet

Waits for a character from the specified port.

Prototype:

Receiver

long UARTCharGet(unsigned long ulBase)

Parameters:

ulBase is the base address of the UART port.

Description:

This function gets a character from the receive FIFO for the specified
port. If there are no characters available, this function waits until a

character is received before returning.

You might also like