Chapter 3 Serial Interfacing With Microprocessor Based System
Chapter 3 Serial Interfacing With Microprocessor Based System
BEL III/I
Presented By
Er. Suwarna Lingden
NEC Regd. No. 8632 'A'
B.E (E&C) , MScInE
TRIBHUVAN UNIVERSITY
INSTITUTE OF ENGINEERING
PURWANCHAL CAMPUS
DHARAN-8
SERIAL INTERFACING WITH MICROPROCESSOR BASED SYSTEM
• Longer data transmission in serial mode as less number of wires is used and
is cheaper to implement.
• Transmission begins with one Start bit (low), followed by a character and
one or two Stop bits (high). This is known as framing.
• This format is generally used for low-speed transmission (less than 20Kbps)
D0 D1 D2 D3 D4 D5 D6 D7
PS : In a little endian system, the least significant byte (the byte with the lowest memory address) is stored
first, followed by the more significant bytes. In a big endian system, the scheme is reversed.
RATE OF TRANSMISSION
• In serial I/O, one bit is sent out at a time; therefore, how long the bit stays on
or off is determined by the speed at which the bits are transmitted.
• Furthermore, the receiver should be set up to receive the bits at the same rate
as the transmission; otherwise, the receiver may not be able to differentiate
between two consecutive 0s and 1s.
Bit Rate and Baud Rate
• Bit rate is the number of bits per second.
• Baud rate is the number of signal changes or signal units per second.
Bit rate ≥ Baud rate
Q) If an analog signal carries 4 bits in each signal unit and if 1000 signal
units are sent per second, then find the baud rate and the bit rate.
Q) The bit rate of a signal is 3000. If each signal unit carries 6 bits, what is the
baud rate?
SERIAL DATA UNIT & SERIALIZATION
• SDU is a unit with 1 start bit, 7 or 8 data bits, 1 parity bit and 1 or 2 stop
bits.
• Start bit always has a value of 0 & stop bits always have a value of 1.
• For asynchronous data transmission, sender and receiver must be set up
to the same format
TRANSMITTING SDU
• The interface chip has a transmitter hold register for transmitting data which
first fetches the data bytes from CPU.
• According to the selected data format, the SDU logic puts the start bit in front
of data bits; it then calculates the parity bit and appends it together with the
stop bits to the data bits.
• Thus formed SDU is transferred into the transmitter shift register, which is
operated by a clock source determined by baud rate and thus provides the
individual bits at the serial output (LSB first). If no data, then the chip
possesses a logical high level
ERRORS IN SERIAL DATA TRANSFER
1. Parity error : The calculated parity does not coincide with the set parity.
i. Even parity,
ii. Odd parity,
iii. Mark parity,
iv. Space parity,
v. No parity
ERRORS IN SERIAL DATA TRANSFER
2. Framing error : Data does not fit into the frame that the data format and
baud rate defined i.e non-synchronized start/stop bit.
3. Break error
• If the reception line is at logic low level for longer time than the SDU
usually lasts, then the receiver assumes that the connection to the
transmitter has broken.
• Unless the transmitter drives the line to a logical high level, no data is
transferred.
ERRORS IN SERIAL DATA TRANSFER
4. Overrun error : If data arriving at the receiver is much faster than it can
be read by the receiver buffer; the latter received byte overwrites the
older data in the buffer.
ERROR CHECKING MECHANISMS
1. Parity check
• This is used to check each character by counting the number of 1s in the character.
• In the ASCII code transmission, bit D7 is used to transmit parity check information.
• Then, the 2's complement of the sum (negative of the sum) is transmitted as
the last byte.
• The receiver adds all the bytes, including the 2's complement of the sum;
thus, the result should be zero if there is no error in the block.
2. Checksum
• For eg. Data blocks 41H, 42H and 43H are to be sent. Their sum is
C6H and 2's complement is 3AH. The receiver would then add all the
data blocks along with the 2's complement of the sum.
• If the result is zero then there is no error else an error is detected and
data is retransmitted.
3. Cyclic Redundancy Check
• A stream of data is represented by a polynomial that is divided by a constant
polynomial, and the remainder is generated.
• The remainder is sent out with data as a check for errors.
• The receiver checks the remainder to detect an error in the transmission.
SIMPLEX AND DUPLEX COMMUNICATION
STANDARDS IN SERIAL I/O
• The serial I/O technique is commonly used to interface terminals,
printers and modems with computers.
• Peripherals
and computers are designed and manufactured by various
manufacturers.
•A standard is normally defined which may include such items as
assignment of pin position for signals, voltage levels, speed of data
transfer, length of cables and mechanical specifications that can
ensure compatibility among different equipments.
STANDARDS IN SERIAL I/O
• In serial I/O, data can be transmitted as either current or voltage.
• When data are transmitted with voltage signal, the commonly used standards
are RS232C , RS423A and RS422A.
RS232
• Connect a DCE device to another DCE device using a null modem (male-to-
male) adaptor.
• Connect a DTE device to another DTE device using a null modem (female-
to-female) adaptor.
RS232
• For data lines, the voltage level +3 V and +15 V is defined as logic 0; from
-3 V to -15 V is defined as logic 1(normally,voltage levels are +/-12V). This
is negative true logic.
• Because of incompatibility of the data lines with the TTL logic, voltage
translators, called line drivers and line receivers, are required to interface
TTL logic with the RS-232 signals.
RS232
• The line driver, MC1488, converts logic 1 into approximately -9V and logic 0
into +9V.
• Before it is received by the DCE, it is again converted by the line receiver,
MC1489, into TTL-compatible logic.
RS232
5 5 5 5
2. Data Set Ready (DSR'): When the modem is powered up and ready to
transmit or receive data, it will assert data set ready (DSR’) to the terminal.
Under manual control or terminal control, modem then dials up the
computer. If the computer is available, it will send back a specified tone.
RS232 SIGNALS USED IN HANDSHAKING
4. Data Carrier Detect (DCD'): The modem will then assert its data-carrier-
detect (DCD’) signal to the terminal to indicate that it has established
connection with the computer.
5. Clear to send (CTS'): When the modem is fully ready to receive data, it
asserts the clear-to-send (CTS’) signal back to the terminal.
RS232 SIGNALS USED IN HANDSHAKING
6. Transmitted Data (TxD): The terminal then sends serial data characters
to the modem.
7. Received Data (RxD): Modem will receive data from terminal through
this line.
• Data Signal Rate Detect (DSRD): It is used for switching different baud
rate.
• Ring Indicator (RI) : Indicate that a ring has occured at modem; it works
independently.
NULL MODEM CONNECTION
• This means that outputs are connected to outputs and inputs are
connected to inputs.
• With this convention, no data transfer is possible.
• For the transmission of data, it is required to twist the TxD and RxD lines.
• In this way, the transmitted data of one terminal (PC) becomes received
data of other and vice versa.
Handshaking null modem connections
Handshaking null modem connections
• Single connector type : USB replaces all the different legacy connectors
with one well-defined, standardized USB connector for all USB peripheral
devices, eliminating the need for different cables and connectors and thus
simplifying the design of the USB devices. So, all USB devices can be
connected directly to a standard USB port on a computer.
• High performance: USB offers low speed (1.5 Mbit/s), full speed (12
Mbit/s) and high speed (up to 480 Mbit/s) transfer rates that can support a
variety of USB peripherals.USB 3.0(SuperSpeed USB) achieves the
throughput up to 5.0 Gbit/s. Latest USB 4 has transfer rate of 40 Gbits/s.
FEATURES OF USB
• Power supplied from the bus: USB distributes the power to all connected
devices eliminating the need for external power source for low-power
devices. High-power devices can still require their own local power supply.
USB also supports power saving suspend/resume modes.
FEATURES OF USB
• Easy to use for end user: A single standard connector type for all USB
devices simplifies the end user's task at figuring out which plugs go into
which sockets. The operating system automatically recognizes the USB
device attachment and loads appropriate device drivers.
• The first packet, also called a token packet is generated by the host to
describe what is to follow and whether the data transaction will be a read or
write and what the device’s address and designated endpoint is.
• The next packet is generally a data packet carrying the payload and is
followed by an handshaking packet, reporting if the data or token was
received successfully, or if the endpoint is stalled or not available to accept
data.
USB Packet Fields
• Data on the USB bus is transmitted LSB first.
• USB packets consist of the following fields :
SYNC
• All packets must start with a sync field.
• The sync field is 8 bits long at low and full speed or 32 bits long for high
speed.
• It is used to synchronize the clock of the receiver with that of the transmitter.
• The last two bits indicate the end of the sync field and, by inference, where
the PID fields starts.
PID
• PID stands for Packet Identifier.
• This field is used to identify the type of packet that is being sent.
• There are 4 bits to the PID and to ensure it is received correctly, the 4 bits are
complemented(n represents complement) and repeated, making an 8 bit
PID in total.
• The resulting format is shown below:
DATA FLOW TYPES
• Control Transfers
Used for the configuration of the USB device.
• OTG specification defines a new type of USB device with both host and
peripheral capabilities called a "dual role device".
• Possess dual role – host or peripheral capability to switch between the two.
• Cell phones can exchange contact lists, phones can attach to printers and print
faxes.
• OTG devices must have Host Negotiation Protocol (HNP) and Session
Request Protocol(SRP).