Universal Asynchronous Receiver Transmitter (UART)
-
Upload
chandresh-trivedi -
Category
Documents
-
view
250 -
download
0
Transcript of Universal Asynchronous Receiver Transmitter (UART)
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
1/38
T . R E V A T H I
T IF AC C O R E I N A U T O M O T I V E I N F O T R O N I C S
V I T U N I V E R S I T Y , V E L L O R E
Serial Communication Interfaces- UART (RS232) , RS485
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
2/38
Contents
Basic Concepts of Serial communication
Types
Advantages
Applications
UART Features in ARM Implementation Steps Transmitter & Receiver
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
3/38
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.
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
4/38
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.
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
5/38
Advantages of Serial Communication
Transmission distance is more.
Cable connection is simpler.
Low Cost in implementation.
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
6/38
Types of Serial communication
Asynchronous serial communication
Universal Asynchronous Receiver Transmitter (UART)
Synchronous serial communication
Serial Peripheral Interface (SPI)
Inter Integrated Circuit (I2C)
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
7/38
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
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
8/38
Data Communication System
Devices that uses serial cables for their communication are
split into two categories
Data Terminal Equipment
Data Communication Equipment
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
9/38
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.
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
10/38
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.
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
11/38
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
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
12/38
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.
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
13/38
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.
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
14/38
Max232 Level conversion circuit
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
15/38
RS 232 Level Conversion
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
16/38
Typical Connection
Types of Connectors
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
17/38
Applications
Dial-up modems
GPS receivers
Bar code scanners
LED and LCD text displays
Satellite Phones
Test and measuring equipment
such as digital multi meters and
weighing systems
Updating Firmware on various
consumer devices.
Industrial field buses
Printers
Computer terminal
Serial mouse
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
18/38
RS 485 Specifications
RS485 is a balanced line, Half-duplextransmission system allowingtransmission distances of up to 1.2 km.
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
19/38
RS-485 Balanced Differential Bus
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
20/38
RS-485 Signaling
For Input
If a logic high is received on the
input of the transmitter (DI = 1),
Line A is more positive than Line B
(VOA > VOB) on the driver output.
If a logic low is received on the
input of the transmitter (DI = 0),
the transmitter causes Line B to bemore positive than Line A (VOB >
VOA).
For Output
If Line A is more positive than line
B (VIA VIB > 200 mV) on the
input of the receiver, the receiver
output is a logic high (RO = 1).
If Line B is more positive than Line
A(VIB VIA > 200 mV) on the
input of the receiver, the receiveroutput is a logic low (RO = 0).
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
21/38
RS 485 Network Topologies
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
22/38
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.
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
23/38
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.
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
24/38
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.
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
25/38
Applications of RS-485
Motor Control
Industrial Automation
Battery powered applications
Tele-communications equipment
Industrial Process Control
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
26/38
Comparison between various serial standards
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
27/38
Features in LM4F120H5QR
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
28/38
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
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
29/38
Block Diagram
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
30/38
UART Signal Mapping
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
31/38
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
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
32/38
SysCtlClockSet
Sets the clocking of the device.
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.
Step 1: Set the clocksource
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
33/38
SysCtlPeripheralEnable
Enables a peripheral.
Prototype:
void SysCtlPeripheralEnable(unsigned long ulPeripheral)
Parameters: ulPeripheral is the peripheral to enable.
Description:
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.
Step 2: Select / Enablethe peripheral
Step 3: Enable the Port
corresponds to the peripheral
function
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
34/38
GPIOPinTypeUART
Configures pin(s) for use by the UART peripheral.
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).
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, andwhere 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.
Step 4: Select the UART
function for the respective pin
Step 5: Enable the Port
corresponds to the
peripheral function
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
35/38
UARTConfigSetExpClk
Sets the configuration of a UART.
Prototype:
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 stopbits, and parity).
Step 6:Configure the Baud
rate, No. of Data bits & Parity
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
36/38
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.
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.
Transmitter
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
37/38
To Receive Data - UARTCharGet
Waits for a character from the specified port.
Prototype:
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.
Receiver
-
7/26/2019 Universal Asynchronous Receiver Transmitter (UART)
38/38