Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
There are two types of communication possible between two devices depending upon the
number of wires required.
1. Parallel communication: In this, more than one wire is connected between two
communicating node. Each bit is sent separately on dedicated wire. In this approach, numbers of
wires required = width of data bus. This is preferred for short way communication. Over a long
distance, this increases cost of wires and maintenance.
2. Serial Communication: In this, data is combined into a packet and sent bit by bit on a single
wire between two communicating devices. This requires less costly implementation and
maintenance. However, synchronization between communicating devices is necessary.
Sometimes separate wires are required for two-way communication. This approach is widely
used for long distance, high speed and reliable communication.
Serial communication using UART (Universal Asynchronous Receiver/Transmitter) is widely
used in embedded systems. Almost all controller has inbuilt UART available for easy
communication. IBM PC also comes with serial COM PORTS so that we can communicate with
them using controllers. Using USB to serial bridge, we can create virtual COM PORTS and
communicate with controllers using the same.
Baud rate is the measurement of speed of data transfer for serial communications. Various baud
rate supported by UART for given maximum distance is as follows.
Controllers are connected with device using DB9 connector. As the name suggests, it has 9 pins
as shown in image. Function of pins required for serial communication are explained below.
1. CD/DCD (CARRIER DETECT/ DATA CARRIER DETECT)
2. RxD (Receiver Pin)
3. TxD (Transmission Pin)
4. DTR (Data Terminal Ready)
5. GND (Signal Ground)
6. DSR (Data Set Ready)
7. RTS (Request To Send)
8. CTS (Clear To Send)
9. RI (Ring Indicator)
Out of these 9 pins, only 3 (RxD, TxD and GND) pins are necessary for serial communication
between PC and controller. Connection is as shown.
LPC 2148 has two UARTs named as UART0 and UART1. UART0 is used for programming
LPC 2148.
U0DLM, U0DLL are standard UART0 baud rate generator divider registers
MULVAL and DIVADDVAL are fraction generator values. They must meet following
conditions.
U0LSR:
The U0LSR (UART0 LINE STATUS REGISTER) is a read-only register that provides status
information on the UART0 TX and RX blocks. It is an 8 bit register. Function of each pin is as
follows.
Bit 0- Receiver Data Ready (RDR)
U0LSR0 is set when the U0RBR holds an unread character and is cleared when the UART0 RBR
FIFO is empty.
0:U0RBR is empty.
1: U0RBR contains valid data
Bit 1- Overrun error (OE)
The overrun error condition is set as soon as it occurs. An U0LSR read clearsU0LSR1. U0LSR1
is set when UART0 RSR has a new character assembled and the UART0 RBR FIFO is full. In
this case, the UART0 RBR FIFO will not be overwritten and the character in the UART0 RSR
will be lost.
0: Overrun error status is inactive
1: Overrun error status is active
Bit 2- Parity Error (PE)
When the parity bit of a received character is in the wrong state, a parity error occurs. An
U0LSR read clears U0LSR [2]. Time of parity error detection is dependent on U0FCR [0].
0: Parity error status is inactive
1: Parity error status is active
Bit 3- Framing Error (FE)
When the stop bit of a received character is at logic 0, a framing error occurs. An U0LSR read
clears U0LSR [3]. The time of the framing error detection is dependent on U0FCR0. Upon
detection of a framing error, the Rx will attempt to resynchronize to the data and assume that the
bad stop bit is actually an early start bit. However, it cannot be assumed that the next received
byte will be correct even if there is no Framing Error.
When RXD0 is held in the spacing state (all 0s) for one full character transmission (start, data,
parity, stop), a break interrupt occurs. Once the break condition has been detected, the receiver
goes idle until RXD0 goes to marking state (all 1s). An U0LSR read clears this status bit. The
time of break detection is dependent on U0FCR[0].
THRE is set immediately upon detection of an empty UART0 THR and is cleared on a U0THR
write.
1: U0THR is empty
Bit 6- TransmitterEmpty(TEMT)
TEMT is set when both U0THR and U0TSR are empty; TEMT is cleared when either the
U0TSR or the U0THR contain valid data.
U0LSR [7] is set when a character with a Rx error such as framing error, parity error or
break interrupt, is loaded into the U0RBR. This bit is cleared when theU0LSR register is read
and there are no subsequent errors in the UART0FIFO.