Sie sind auf Seite 1von 42

UNIT-3 I/O and Memory Interfacing with 8051

 Memory Interfacing with 8051

8051 Microcontroller Memory Organization

The 8051 Microcontroller Memory is separated in Program Memory (ROM) and Data Memory
(RAM). The Program Memory of the 8051 Microcontroller is used for storing the program to be
executed i.e. instructions. The Data Memory on the other hand, is used for storing temporary variable
data and intermediate results.

8051 Microcontroller has both Internal ROM and Internal RAM. If the internal memory is
inadequate, you can add external memory using suitable circuits.

Interfacing External Memory with 8051 Microcontroller

We have seen that a typical 8051 Microcontroller has 4KB of ROM and 128B of RAM (most modern
8051 Microcontroller variants have 8K ROM and 256B of RAM).
The designer of an 8051 Microcontroller based system is not limited to the internal RAM and ROM
present in the 8051 Microcontroller. There is a provision of connecting both external RAM and ROM
i.e. Data Memory and Program.

The reason for interfacing external Program Memory or ROM is that complex programs written in
high – level languages often tend to be larger and occupy more memory.

Another important reason is that chips like 8031 or 8032, which doesn’t have any internal ROM, have
to be interfaced with external ROM.

A maximum of 64B of Program Memory (ROM) and Data Memory (RAM) each can be interface
with the 8051 Microcontroller.

The following image shows the block diagram of interfacing 64KB of External RAM and 64KB of
External ROM with the 8051 Microcontroller.

LCD Interfacing with 8051 Microcontroller


Display units are the most important output devices in embedded projects and electronics products.
16x2 LCD is one of the most used display unit. 16x2 LCD means that there are two rows in which 16
characters can be displayed per line, and each character takes 5X7 matrix space on LCD. In this
tutorial we are going to connect 16X2 LCD module to the 8051 microcontroller
(AT89S52). Interfacing LCD with 8051 microcontroller might look quite complex to newbies, but
after understanding the concept it would look very simple and easy. Although it may be time taking
because you need to understand and connect 16 pins of LCD to the microcontroller. So first let's
understand the 16 pins of LCD module.

Category Pin NO. Pin Name Function


1 VSS Ground Pin, connected to Ground
Power Pins
2 VDD or Vcc Voltage Pin +5V
Contrast Pin 3 V0 or VEE Contrast Setting, connected to Vcc thorough a
variable resistor.
Register Select Pin, RS=0 Command mode,
4 RS
RS=1 Data mode
Read/ Write pin, RW=0 Write mode,
Control Pins 5 RW
RW=1 Read mode
Enable, a high to low pulse need to enable the
6 E
LCD
Data Pins, Stores the Data to be displayed on LCD
Data Pins 7-14 D0-D7
or the command instructions
15 LED+ or A To power the Backlight +5V
Backlight Pins
16 LED- or K Backlight Ground

All the pins are clearly understandable by their name and functions, except the control pins, so they
are explained below:

RS: RS is the register select pin. We need to set it to 1, if we are sending some data to be displayed
on LCD. And we will set it to 0 if we are sending some command instruction like clear the screen
(hex code 01).

RW: This is Read/write pin, we will set it to 0, if we are going to write some data on LCD. And set
it to 1, if we are reading from LCD module. Generally this is set to 0, because we do not have need to
read data from LCD. Only one instruction “Get LCD status”, need to be read some times.

E: This pin is used to enable the module when a high to low pulse is given to it. A pulse of 450 ns
should be given. That transition from HIGH to LOW makes the module ENABLE.

There are some preset command instructions in LCD, we have used them in our program below to
prepare the LCD (in lcd_init() function). Some important command instructions are given below:

Hex Code Command to LCD Instruction Register


0F LCD ON, cursor ON
01 Clear display screen
02 Return home
04 Decrement cursor (shift cursor to left)
06 Increment cursor (shift cursor to right)
05 Shift display right
07 Shift display left
0E Display ON, cursor blinking
80 Force cursor to beginning of first line
C0 Force cursor to beginning of second line
38 2 lines and 5×7 matrix
83 Cursor line 1 position 3
3C Activate second line
08 Display OFF, cursor OFF
C1 Jump to second line, position 1
OC Display ON, cursor OFF
C1 Jump to second line, position 1
C2 Jump to second line, position 2

Circuit Diagram and Explanation

Circuit diagram for LCD interfacing with 8051 microcontroller is shown in the above figure. If you
have basic understanding of 8051 then you must know about EA(PIN 31), XTAL1 & XTAL2, RST
pin(PIN 9), Vcc and Ground Pin of 8051 microcontroller. I have used these Pins in above circuit. If
you don’t have any idea about that then I recommend you to read this Article LED Interfacing with
8051 Microcontroller before going through LCD interfacing.
So besides these above pins we have connected the data pins (D0-D7) of LCD to the Port 2 (P2_0 –
P2_7) microcontroller. And control pins RS, RW and E to the pin 12,13,14 (pin 2,3,4 of port 3) of
microcontroller respectively.

PIN 2(VDD) and PIN 15(Backlight supply) of LCD are connected to voltage (5v), and PIN 1 (VSS)
and PIN 16(Backlight ground) are connected to ground.

Pin 3(V0) is connected to voltage (Vcc) through a variable resistor of 10k to adjust the contrast of
LCD. Middle leg of the variable resistor is connected to PIN 3 and other two legs are connected to
voltage supply and Ground.

Interfacing the Keyboard to 8051 microcontroller

A keypad is a set of buttons arranged in a block or "pad" which usually bear digits, symbols and
usually a complete set of alphabetical letters. If it mostly contains numbers then it can also be called a
numeric keypad. Here we are using 4 X 4 matrix keypad…

Circuit diagram of INTERFACING KEY BOARD TO 8051.

Interfacing keypad

Fig. 1
shows how
to interface
the 4 X 4
matrix
keypad to
two ports in

microcontroller. The rows are connected to an output port and the columns are connected to an
input port.
To detect a pressed key, the microcontroller grounds all rows by providing 0 to the output latch, and
then it reads the columns. If the data read from the columns is D3-D0=1111, no key has been pressed
and the process continues until a key press is detected. However, if one of the column bits has a zero,
this means that a key press has occurred. For example, if D3-D0=1101, this means that a key in the
D1 column has been pressed.

After a key press is detected, the microcontroller will go through the process of identifying the key.
Starting with the top row, the microcontroller grounds it by providing a low to row D0 only; then it
reads the columns.

If the data read is all 1s, no key in that row is activated and the process is moved to the next row. It
grounds the next row, reads the columns, and checks for any zero. This process continues until the
row is identified. After identification of the row in which the key has been pressed, the next task is to
find out which column the pressed key belongs to.

The programming algorithm, program and the circuit diagram is as follows. Here program is
explained with comments.

We normally use 8*8 matrix key board. So only two ports of 8051 can be easily connected to the
rows and columns of the key board.

Circuit diagram of INTERFACING KEY BOARD TO 8051.

Keyboard is organized in a matrix of rows and columns as shown in the figure. The microcontroller
accesses both rows and columns through the port.

1. The 8051 has 4 I/O ports P0 to P3 each with 8 I/O pins, P0.0 to P0.7,P1.0 to P1.7, P2.0
to P2.7, P3.0 to P3.7. The one of the port P1 (it understood that P1 means P1.0 to P1.7)
as an I/P port for microcontroller 8051, port P0 as an O/P port of microcontroller 8051
and port P2 is used for displaying the number of pressed key.
2. Make all rows of port P0 high so that it gives high signal when key is pressed.
3. See if any key is pressed by scanning the port P1 by checking all columns for non
zero condition.

4. If any key is pressed, to identify which key is pressed make one row high at a time.

5. Initiate a counter to hold the count so that each key is counted.

6. Check port P1 for nonzero condition. If any nonzero number is there in [accumulator],
start column scanning by following step 9.

7. Otherwise make next row high in port P1.

8. Add a count of 08h to the counter to move to the next row by repeating steps from
step 6.

9. If any key pressed is found, the [accumulator] content is rotated right through the
carry until carry bit sets, while doing this increment the count in the counter till carry
is found.

10. Move the content in the counter to display in data field or to memory location

11. To repeat the procedures go to step 2.

Interfacing ADC0808 with microcontroller 8051


Introduction

DC0808 is one of the useful chips from National Semiconductor. See in figure given aside. In lot of embedded
systems micro controllers needs to take analog input. Most of the sensors AND transducers such as
temperature, humidity, pressure, are analog. For interfacing these sensors to micro controllers we require to
convert the analog output of these sensors to digital so that the controller can read it. Some micro controllers
have built in Analog to Digital Converter (ADC) so there is no need of external ADC. For controllers that
don’t have internal ADC external ADC is used.
One of the most commonly used ADC is ADC0808. ADC 0808 is a Successive approximation type with 8
channels i.e. it can directly access 8 single ended analog signals. ADC0808 has an 8-bit data output just like
the ADC804. The 8 analog input channels are multiplexed and selected according to table given below I/O pins
using three address pins A, B, and C.
Features of ADC 0808
1. Inbuilt 8 analog channels with multiplexer
2. Zero or full scale adjustment is not required
3. 0 to 5V input voltage range with a single polarity 5V
supply
4. Output is TTL compatible
5. High speed
6. Low conversion time (100micro second)
7. High accuracy
8. 8-bit resolution
9. Low power consumption (less than 15mW)
10. Easy to interface with all microprocessor
11. Minimum temperature dependence

Description
· ADC devices - Analog-to-digital converters are
among the most widely used devices for data acquisition.
Digital computers use binary (discrete) values, but in the
physical world everything is analog. Temperature, pressure,
humidity and velocity are a few examples of physical
quantities that we deal with everyday. A physical quantity
can be converted into electrical signals using a device
called as transducer. Transducers are also referred to as
sensors. We need an analog to digital converter to translate he
analog signals to digital numbers so that the microcontroller can
read and process them. An ADC has n-bit resolution where n can be
8, 10, 12, 16 or even 24 bits. The highest-resolution ADC size,
where step size is the smallest change that can be discerned by an
ADC.
· CS - Chip select is an active low input used to activate the
ADC0808 chip. To access the ADC0804, this pin must be low.
. RD (read) - This is an input signal and is active low. The ADC
converts the analog input to its binary equivalent and holds it in an
internal register. RD is used to get the converted data out of the
ADC0808 chip. When CS=0, if a high-to-low pulse is applied to
the RD pin, the 8-bit digital output shows up at the D0 – D7 data
pins. The RD pin is also referred to as output enable (OE).
· WR (write; start conversion) - This is an active low input used to inform the ADC0808 to start the
conversion process. If CS=0 when WR makes a low-to-high transition, the ADC0808 starts converting the
analog input value of Vin to an 8-bit digital number. The amount of time it takes to convert varies depending on
the CLK IN and CLK R values explained below. When the data conversion is complete, the INTR pin is forced
low by the ADC0808.
· ADDRESS LINE A, B, C - The device contains 8-channels. A particular channel is selected by using
the address decoder line. The TABLE 1 shows the input states for address lines to select any channel.
· Address Latch Enable (ALE) - The address is latched on the Low – High transition of ALE.
· START - The ADC’s Successive Approximation Register (SAR) is reset on the positive edge i.e. Low-
High of the Start Conversion pulse. Whereas the conversion is begun on the falling edge i.e. High – Low of the
pulse.
· Output Enable - Whenever data has to be read from the ADC, Output Enable pin has to be pulled high
thus enabling the TRI-STATE outputs, allowing data to be read from the data pins D0-D7.
· End of Conversion (EOC) - This pin becomes High when the conversion has ended, so the controller
comes to know that the data can now be read from the data pins.
· Clock - External clock pulses are to be given to the ADC; this can be given either from LM 555 in
Astable mode or the controller can also be used to give the pulses.
· D0 – D7 - D0- D7 are the digital data output pins since ADC0808 is a parallel ADC chip. These are tri
state buffered and the converted data is accessed only when CS=0 and RD is forced low. To calculate the
output voltage, we can use following formula
Dout = Vin / step size
Where Dout = digital data output, Vin = analog input voltage, and step size is the smallest input change.

Calculating Step Size


ADC 0808 is an 8 bit ADC i.e. it divides the voltage applied at Vref+ & Vref- into 28 i.e. 256 steps.
Step Size = (Vref+ -Vref-)/256
Suppose Vref+ is connected to Vcc i.e. 5V & Vref- is connected to the Gnd then the step size will be
Step size= (5 - 0)/256= 19.53 mV.

Calculating Dout
The data we get at the D0 - D7
depends upon the step size & the
Input voltage i.e. Vin.
Dout = Vin /step Size.
If you want to
interface sensors like LM35 which
has output 10mv/°C then I would
suggest that you set the Vref+to 2.56v
so that the step size will be
Step size= (2.56 - 0)/256= 10 mV.
So now whatever reading that you get
from the ADC will be equal to the
actual temperature.
Functional block diagram of IC ADC 0808

DAC INTERFACING

SECTION 13.2: DAC INTERFACING


This section will show how to interface a DAC (digital-to-analog converter) to the 8051. Then we demonstrate
how to generate a sine wave on the scope using the DAC.
Digital-to-analog (DAC) converter
The digital-to-analog converter (DAC) is a device widely used to convert digital pulses to analog signals. In
this section we discuss the basics of interfacing a DAC to the 8051.
Recall from your digital electronics book the two methods of creating a DAC: binary weighted and R/2R
ladder. The vast majority of integrated circuit DACs, including the MC1408 (DAC0808) used in this section,
use the R/2R method since it can achieve a much higher degree of precision. The first criterion for judging a
DAC is its resolution, which is a function of the number of binary inputs. The common ones are 8, 10, and 12
bits. The number of data bit inputs decides the resolution of the DAC since the number of analog output levels
is equal to 2″, where n is the number of data bit inputs. Therefore, an 8-input DAC
such as the DAC0808 provides 256 discrete voltage (or current) levels of output.
Similarly, the 12-bit DAC provides 4096 discrete voltage levels. There are also
16-bit DACs, but they are more expensive.
MC1408 DAC (or DAC0808)
In the MC1408 (DAC0808), the digital inputs are converted to current (I out), and by
connecting a resistor to the Ioutpin, we convert the result to voltage.
The total current provided by the Iout pin is a function of the binary numbers at the DO – D7
inputs of the DAC0808 and the reference current (I ref), and is as follows:

Figure 13-18. 8051 Connection to DAC808


Example 13-3
OBJECTIVE BITS
1.The internal RAM memory of the 8051 is:
A. 32 bytes, B. 64 bytes, C. 128 bytes, D. 256 bytes

2.The 8051 has ________ 16-bit counter/timers.

A.2. , B.3. C.4. D.5

3. Data transfer from I/O to external data memory can only be done with the MOVX command.
A. True B. False

4. The 8051 can handle ________ interrupt sources.

A.3, B.4, C.5, D.6

5. This statement will set the address of the bit to 1 (8051 Micro-controller):
SETB 01H

A. True
B. False

6. MOV A, @ R1 will:

A. copy R1 to the accumulator


B. copy the accumulator to R1
C. copy the contents of memory whose address is in R1 to the accumulator
D. copy the accumulator to the contents of memory whose address is in R1

7. A label is used to name a single line of code.

A. True
B. False

8. Device pins XTAL1 and XTAL2 for the 8051 are used for connections to an external oscillator or
crystal.

A. True
B. False

9. When the 8051 is reset and the line is HIGH, the program counter points to the first program
instruction in the:

A. internal code memory, B. external code memory


C. internal data memory, D. external data memory

10. The following command will rotate the 8 bits of the accumulator one position to the left:
RL A
A. True, B. False

11.An alternate function of port pin P3.0 (RXD) in the 8051 is:

A. serial port input, B. serial port output


C. memory write strobe, D. memory read strobe

12. Which of the following commands will copy the contents of RAM whose address is in register 0 to
port 1?

A. MOV @ P1, R0, B. MOV @ R0, P1


C. MOV P1, @ R0, D. MOV P1, R0

13. Serial port vector address is of _______. And causes an interrupt when ________.
a) 0013H, either TI or RI flag is set, b) 0023H, either TI or RI flag is reset
c) 0013H, either TI or RI flag is reset, d) 0023H, either TI or RI flag is set

14. In serial communication modes, mode 1 the Baud rate =


a) BR=2SMOD/32 * (Timer 0 over flow rate), b) BR=2SMOD/16 * (Timer 1 over flow rate)
c) BR=2SMOD/16 * (Timer 0 over flow rate), d) BR=2SMOD/32 * (Timer 1 over flow rate)

15. Interfacing LCD with 89C51 _____ data lines are used along with the _____ signals.
a) 6, RS, RW b) 5, RW, EN c) 8, RS, EN, RW d) 9, RS, EN, RW

16. Resolution of ADC is defined as


a) 1/ (2N – 1) b) 2N-1 c) 1/ (2N-1) d) 2N-1

17. In ADC interfacing IC used to interface with 8051 generally

a)0808 b) 8080 c) 8086 d) 8956

18. SOC stands for _________________________

19. EOC stands for __________________________

20. In 16*2 LCD, 16 indicates__________________________

21.

22.
In LCD interfacing
Contrast Pin 3V0 or VEE Contrast Setting, connected to Vcc thorough a variable resistor.

24. The rows are connected to an output port and the columns are connected to an input port. (T/F )

25 connected to an output port and the columns are connected to an input port. (T/F)

26. To detect a pressed key, the microcontroller grounds all rows by providing 1 to the output latch (T/F)

27. If the data read from the columns is D3-D0=1100, no key has been pressed (T/F)
28. However, if one of the column bits has a zero, this means that a key press has occurred. For
example, if D3-D0=1101, this means that a key in the D1 column has been pressed. (T/F)

29. In 8051 ADC interfacing the no of selection lines _____________________

PART-II
Serial communication and Bus Interfaces

3.2.1Serial Communication of 8051

The serial port of 8051 is full duplex, i.e., it can transmit and receive Simultaneously.

The register SBUF is used to hold the data. The special function register SBUF is
physically two registers.

One is, write-only and is used to hold data to be transmitted out of the 8051 via TXD.

The other is, read-only and holds the received data from external sources via RXD.
Both mutually exclusive registers have the same address 099H.
SBUF receives or transmits data protocol/packet

Start bit 8 data bits 1 parity bit (from PSW) 1 or 2 stop bits

Serial Port Control Register (SCON)


 Register SCON controls serial data communication.
Address: 098H (Bit addressable

Data Transmission
 Transmission of serial data begins at any time when data is
written to SBUF.
 Pin P3.1 (Alternate function bit TXD) is used to transmit data to
the serial data network.
 TI is set to 1 when data has been transmitted. This signifies that
SBUF is empty so that another byte can be sent.

Data Reception
 Reception of serial data begins if the receive enable bit is set to 1
for all modes.
 Pin P3.0 (Alternate function bit RXD) is used to receive data from
the serial data network.
 Receive interrupt flag, RI, is set after the data has been received
in all modes. The data gets stored in SBUF register from where it can be
read.

Serial Data Modes


8051 micro controller communicate with another peripheral device
through RXD and TXD pin of port3.controller have four mode of serial
communication.this four mode of serial communication are below.
1. Serial data mode 0-fixed buad Rate.
2. Serial data mode 1-variable baud rate.
3. Serial data mode 2 -fixed baud Rate.
4. Serial Data mode 3 -variable baud rate.

Serial Data Mode-0


(Baud Rate Fixed)

 In this mode, the serial port works like a shift register and the data
transmission works synchronously with a clock frequency of f osc /12.
 Serial data is received and transmitted through RXD. 8 bits are
transmitted/ received aty a time.
 Pin TXD outputs the shift clock pulses of frequency f osc /12, which
is connected to the external circuitry for synchronization.
 The shift frequency or baud rate is always 1/12 of the oscillator
frequency.

Serial Data Mode-1 (standard UART mode)


(baud rate is variable)
 In mode-1, the serial port functions as a standard Universal
Asynchronous Receiver Transmitter (UART) mode. 10 bits are
transmitted through TXD or received through RXD.
 The 10 bits consist of one start bit (which is usually '0'), 8 data
bits (LSB is sent first/received first), and a stop bit (which is usually '1').
Once received, the stop bit goes into RB8 in the special function
register SCON. The baud rate is variable.

f baud = (2 SMOD /32) * ( fosc / 12 (256-TH1))


Serial Data Mode-2 Multiprocessor
(baud rate is fixed)
 In this mode 11 bits are transmitted through TXD or received through RXD.
 The various bits are as follows: a start bit (usually '0'), 8 data bits (LSB first), a
programmable 9 th (TB8 or RB8)bit and a stop bit (usually '1').
 While transmitting, the 9 th data bit (TB8 in SCON) can be assigned the value '0' or
'1'. For example, if the information of parity is to be transmitted, the parity bit (P) in PSW
could be moved into TB8.
 On reception of the data, the 9 th bit goes into RB8 in 'SCON', while the stop bit is
ignored.
 The baud rate is programmable to either 1/32 or 1/64 of the oscillator frequency.

f baud = (2 SMOD /64) fosc

Serial Data Mode-3 - Multi processor mode


(Variable baud rate)
 In this mode 11 bits are transmitted through TXD or received
through RXD.
 The various bits are: a start bit (usually '0'), 8 data bits (LSB first),
a programmable 9 th bit and a stop bit (usually '1').
 Mode-3 is same as mode-2, except the fact that the baud rate in
mode-3 is variable (i.e., just as in mode-1).
f baud = (2 SMOD /32) * ( fosc / 12 (256-TH1))
http://techknowlearn.blogspot.com/2013/09/serial-communication-of-8051.html

3.2..2 Serial communication Bus Interfaces:


A. Serial Communication Standards:

De Jure and De Facto standards

De jure standards, or standards according to law, are endorsed by a formal standards


organization. The organization ratifies each standard through its official procedures and
gives the standard its stamp of approval.

De facto standards, or standards in actuality, are adopted widely by an industry and its
customers. They are also known as market-driven standards. These standards arise when a
critical mass simply likes them well enough to collectively use them. Market-
drivenstandards can become de jure standards if they are approved through a formal
standards organization.

Formal standards organizations that create de jure standards have well-documented


processes that must be followed. The processes can seem complex or even rigid. But they are
necessary to ensure things like repeatability, quality, and safety. The standards organizations
themselves may undergo periodic audits.

De facto standards are brought about in a variety of ways. They can be closed or open,
controlled or uncontrolled, owned by a few or by many, available to everyone or only to
approved users. De facto standards can include proprietary and open standards alike.

Proprietary Standards

Closed proprietary standards are owned by a single company. Only that company’s
customers and partners are allowed to use them. Competitors are banned from
implementing products that use closed proprietary standards. As a result, they greatly
reduce interoperability. They can be developed quickly, though, and they’re generally well
supported. They also can give a big boost to their owner’s business. Developing something
that customers love and blocking the competition with a closed proprietary standard can
bring in revenue galore.

Open proprietary standards also are owned by a single company, yet the company allows
anyone to use them. Interoperability is enabled with open proprietary standards. There is
usually some kind of license involved and possibly a fee that must be reasonable and non-
discriminatory (RAND)

3.2.2 Transmission modes

Simplex, Half-Duplex, and Full-Duplex Connections


There are 3 different transmission modes that are characterized according to the direction of
the exchanges: a simplex connection, a half-duplex connection, and a full-duplex
connection.
A simplex connection is a connection in which the data flows in
only one direction, from the transmitter to the receiver. This type
of connection is useful if the data does not need to flow in both
directions (for example, from your computer to the printer, from
the mouse to your computer, etc.):

A half-duplex connection, sometimes called an alternating


connection or semi-duplex, is a connection in which the data
flows in one direction or the other, but not both at the same time.
With this type of connection, each end of the connection transmits
in turn. This type of connection makes it possible to have
bidirectional communications using the full capacity of the line:

A full-duplex connection is a connection in which the data


flows in both directions simultaneously. Each end of the line
can, thus, transmit and receive at the same time, which means
that the bandwidth is divided in two for each direction of data
transmission if the same transmission medium is used for both
directions of transmission:

Serial and Parallel Transmission


The transmission mode refers to the number of elementary units of information (bits) that
can be simultaneously translated by the communications channel. In fact, recent processors
(and, therefore, computers in general) never process a single bit at a time; generally they
are able to process several — most of the time it is 8: one byte— and for this reason the
basic connections on a computer are parallel connections.
Parallel Connection

Parallel connection means simultaneous transmission of N bits. These bits are sent
simultaneously over N different channels (a channel being, for example, a wire, a cable, or
any other physical medium). The parallel
connection on PC-type computers generally requires
10 wires:

These channels may be: N physical lines: in which


case each bit is sent on a physical line (which is why
parallel cables are made up of several wires in a ribbon cable); or one physical line divided
into several sub-channels by dividing up the bandwidth (in which case each bit is sent at a
different frequency).

Since the conductive wires are close to each other in the ribbon cable, interference can
occur (particularly at high speeds), and degrade the signal quality.

Serial Connection

In a serial connection, the data is sent one bit at a


time over the transmission channel. However, since
most processors process data in parallel, the
transmitter needs to transform incoming parallel data
into serial data and the receiver needs to do the
opposite:

Asynchronous and Synchronous Transmission


Given the problems that arise with a parallel-type connection, serial connections are normally used.
However, since a single wire transports the information, the problem is how to synchronize the
transmitter and receiver. In other words, the receiver can not necessarily distinguish the characters (or
more generally the bit sequences) because the bits are sent one after the other.

There are two types of transmission that address this problem: an asynchronous connection and a
synchronous connection.
In an asynchronous connection, each character is sent at irregular intervals in time. For example,
imagine that a single bit is transmitted during a long period of silence. The receiver will not be able to
know if this is 00010000, 10000000, or 00000100. To remedy this problem, each character is
preceded by some information indicating the start of character transmission (the transmission start
information is called a START bit) and ends by sending end-of-transmission information (called
STOP bit). There may even be several STOP bits.

In a synchronous connection, the transmitter and receiver are paced by the same clock. The receiver
continuously receives the information at the same rate that the transmitter sent it (even when no bits
are transmitted). This is why the transmitter and receiver are paced at the same speed. In addition,
supplementary information is inserted to guarantee that there are no errors during transmission.

During synchronous transmission, the bits are sent successively with no separation between each
character, so it is necessary to insert synchronization elements; this is called character-level
synchronization.

The main disadvantage of synchronous transmission is recognizing the data at the receiver, as there
may be differences between the transmitter and receiver clocks. That is why each data transmission
must be sustained long enough for the receiver to distinguish it. As a result, the transmission speed
can not be very high in a synchronous link.

3.2.3 Communication interfaces are of two types: Onboard and off (external) interfaces.
A. Onboard interfaces are : I2C, SPI, UART
B. External interfaces : RS-232, USB
A. Onboard interfaces are : I2C, SPI, UART

I2C BUS: Inter Integrated Circuit BUS:


I2C is a serial protocol for two-wire interface to connect low-speed devices like microcontrollers,
EEPROMs, A/D and D/A converters, I/O interfaces and other similar peripherals in embedded
systems. It was invented by Philips and now it is used by almost all major IC manufacturers.
I2C bus is popular because it is simple to use, there can be more than one
master, only upper bus speed is defined and only two wires with pull-up
resistors are needed to connect almost unlimited number of I2C devices.
I2C can use even slower microcontrollers with general-purpose I/O pins
since they only need to generate correct Start and Stop conditions in
addition to functions for reading and writing a byte.
Each slave device has a unique address. Transfer from and to master
device is serial and it is split into 8-bit packets. All these simple
requirements make it very simple to implement I2C interface even with
cheap microcontrollers that have no special I2C hardware controller. You
only need 2 free I/O pins and few simple i2C routines to send and receive
commands.

The initial I2C specifications defined maximum clock frequency of 100


kHz. This was later increased to 400 kHz as Fast mode. There is also a
High speed mode which can go up to 3.4 MHz and there is also a 5 MHz
ultra-fast mode.
I2C Interface

I2C uses only two wires: SCL (serial clock) and SDA (serial data). Both
need to be pulled up with a resistor to +Vdd. There are also I2C level
shifters which can be used to connect to two I2C buses with different
voltages.

I2C Addresses

Basic I2C communication is using transfers of 8 bits or bytes. Each I2C


slave device has a 7-bit address that needs to be unique on the bus. Some
devices have fixed I2C address while others have few address lines which
determine lower bits of the I2C address. This makes it very easy to have
all I2C devices on the bus with unique I2C address. There are also devices
which have 10-bit address as allowed by the specification.
7-bit address represents bits 7 to 1 while bit 0 is used to signal reading
from or writing to the device. If bit 0 (in the address byte) is set to 1 then
the master device will read from the slave I2C device.
Master device needs no address since it generates the clock (via SCL)
and addresses individual I2C slave devices.

I2C Protocol

In normal state both lines (SCL and SDA) are high. The communication is
initiated by the master device. It generates the Start condition (S) followed
by the address of the slave device (B1). If the bit 0 of the address byte
was set to 0 the master device will write to the slave device (B2).
Otherwise, the next byte will be read from the slave device. Once all bytes
are read or written (Bn) the master device generates Stop condition (P).
This signals to other devices on the bus that the communication has
ended and another device may use the bus.
Most I2C devices support repeated start condition. This means that before
the communication ends with a stop condition, master device can repeat
start condition with address byte and change the mode from writing to
reading.

HOW I2C WORKS

With I2C, data is transferred in messages. Messages are broken up into frames of data. Each message has an
address frame that contains the binary address of the slave, and one or more data frames that contain the
data being transmitted. The message also includes start and stop conditions, read/write bits, and ACK/NACK
bits between each data frame:
Start Condition: The SDA line switches from a high voltage level to a low voltage level before the
SCL line switches from high to low.

Stop Condition: The SDA line switches from a low voltage level to a high voltage level after the SCL
line switches from low to high.

Address Frame: A 7 or 10 bit sequence unique to each slave that identifies the slave when the master
wants to talk to it.

Read/Write Bit: A single bit specifying whether the master is sending data to the slave (low voltage
level) or requesting data from it (high voltage level).

ACK/NACK Bit: Each frame in a message is followed by an acknowledge/no-acknowledge bit. If an


address frame or data frame was successfully received, an ACK bit is returned to the sender from the
receiving device.

ADDRESSING

I2C doesn’t have slave select lines like SPI, so it needs another way to let the slave know that data is
being sent to it, and not another slave. It does this by addressing. The address frame is always the first
frame after the start bit in a new message.

The master sends the address of the slave it wants to communicate with to every slave connected to it.
Each slave then compares the address sent from the master to its own address. If the address matches,
it sends a low voltage ACK bit back to the master. If the address doesn’t match, the slave does
nothing and the SDA line remains high.

READ/WRITE BIT
The address frame includes a single bit at the end that informs the slave whether the master wants to
write data to it or receive data from it. If the master wants to send data to the slave, the read/write bit
is a low voltage level. If the master is requesting data from the slave, the bit is a high voltage level.

THE DATA FRAME

After the master detects the ACK bit from the slave, the first data frame is ready to be sent.

The data frame is always 8 bits long, and sent with the most significant bit first. Each data frame is
immediately followed by an ACK/NACK bit to verify that the frame has been received successfully.
The ACK bit must be received by either the master or the slave (depending on who is sending the
data) before the next data frame can be sent.

After all of the data frames have been sent, the master can send a stop condition to the slave to halt
the transmission. The stop condition is a voltage transition from low to high on the SDA line after a
low to high transition on the SCL line, with the SCL line remaining high.

MULTIPLE MASTERS WITH MULTIPLE SLAVES

Multiple masters can be connected to a single slave or multiple slaves. The problem with multiple masters in
the same system comes when two masters try to send or receive data at the same time over the SDA line. To
solve this problem, each master needs to detect if the SDA line is low or high before transmitting a message. If
the SDA line is low, this means that another master has control of the bus, and the master should wait to send
the message. If the SDA line is high, then it’s safe to transmit
the message. To connect multiple masters to multiple slaves,
use the following diagram, with 4.7K Ohm pull-up resistors
connecting the SDA and SCL lines to Vcc:

SDA (Serial Data) – The line for the master and slave to send
and receive data.

SCL (Serial Clock) – The line that carries the clock signal.

I2C is a serial communication protocol, so data is transferred


bit by bit along a single wire (the SDA line).

Like SPI, I2C is synchronous, so the output of bits is


synchronized to the sampling of bits by a clock signal shared
between the master and the slave. The clock signal is always
controlled by the master.

ADVANTAGES AND DISADVANTAGES OF I2C


There is a lot to I2C that might make it sound complicated compared to other protocols, but there are
some good reasons why you may or may not want to use I2C to connect to a particular device:

ADVANTAGES
 Only uses two wires

 Supports multiple masters and multiple slaves

 ACK/NACK bit gives confirmation that each frame is transferred successfully

 Hardware is less complicated than with UARTs

 Well known and widely used protocol

DISADVANTAGES
 Slower data transfer rate than SPI

 The size of the data frame is limited to 8 bits

 More complicated hardware needed to implement than SPI

SPI BUS: Serial Peripheral Interface BUS:

What's Wrong with Serial Ports?

A common serial port, the kind with TX and RX lines, is called “asynchronous” (not synchronous)
because there is no control over when data is sent or any guarantee that both sides are running at
precisely the same rate. Since computers normally rely on everything being synchronized to a single
“clock” (the main crystal attached to a computer that drives everything), this can be a problem when
two systems with slightly different clocks try to communicate with each other.

To work around this problem, asynchronous serial connections add extra start and stop bits to each
byte help the receiver sync up to data as it arrives. Both sides must also agree on the transmission
speed (such as 9600 bits per second) in advance. Slight difference.
Asynchronous serial works just fine, but has a lot of overhead in both the extra start and stop bits sent
with every byte, and the complex hardware required to send and receive data. And as you’ve probably
noticed in your own projects, if both sides aren’t set to the same speed, the received data will be
garbage. This is because the receiver is sampling the bits at very specific times (the arrows in the
above diagram). If the receiver is looking at the wrong times, it will see the wrong bits.

A Synchronous Solution

SPI works in a slightly different manner. It’s a “synchronous” data bus, which means that it uses
separate lines for data and a “clock” that keeps both sides in perfect sync. The clock is an oscillating
signal that tells the receiver exactly when to sample the bits on the data line. This could be the rising
(low to high) or falling (high to low)
edge of the clock signal; the datasheet
will specify which one to use. When the
receiver detects that edge, it will
immediately look at the data line to read
the next bit (see the arrows in the below
diagram). Because the clock is sent
along with the data, specifying the speed
isn’t important, although devices will
have a top speed at which they can
operate (We’ll discuss choosing the
proper clock edge and speed in a bit).

One reason that SPI is so popular is that the receiving hardware can be a simple shift register. This is
a much simpler (and cheaper!) piece of hardware than the full-up UART (Universal Asynchronous
Receiver / Transmitter) that asynchronous serial requires.

Receiving Data

You might be thinking to yourself, self, that sounds great for one-way communications, but how do
you send data back in the opposite direction? Here’s where things get slightly more complicated.

In SPI, only one side generates the clock signal (usually called CLK or SCK for Serial ClocK). The
side that generates the clock is called the “master”, and the other side is called the “slave”. There is
always only one master (which is almost always your microcontroller), but there can be multiple
slaves (more on this in a bit).

When data is sent from the master to a slave, it’s sent on a data line called MOSI, for “Master Out /
Slave In”. If the slave needs to send a response back to the master, the master will continue to
generate a prearranged number of clock cycles, and the slave will put the data onto a third data line
called MISO, for “Master In / Slave Out”.
Notice we said “prearranged” in the above description. Because the master always generates the clock
signal, it must know in advance when a slave needs to return data and how much data will be
returned. This is very different than asynchronous serial, where random amounts of data can be sent
in either direction at any time. In practice this isn’t a problem, as SPI is generally used to talk to
sensors that have a very specific command structure. For example, if you send the command for “read
data” to a device, you know that the device will always send you, for example, two bytes in return.
(In cases where you might want to return a variable amount of data, you could always return one or
two bytes specifying the length of the data and then have the master retrieve the full amount.)

Note that SPI is “full duplex” (has separate send and receive lines), and, thus, in certain situations,
you can transmit and receive data at the same time (for example, requesting a new sensor reading
while retrieving the data from the previous one). Your device’s datasheet will tell you if this is
possible.

Slave Select (SS)

There’s one last line you should be aware of, called SS for Slave Select. This tells the slave that it
should wake up and receive / send data and is also used when multiple slaves are present to select the
one you’d like to talk to.
The SS line is normally held high, which disconnects the slave from the SPI bus. (This type of logic
is known as “active low,” and you’ll often see used it for enable and reset lines.) Just before data is
sent to the slave, the line is brought low, which activates the slave. When you’re done using the slave,
the line is made high again. In a shift register, this corresponds to the “latch” input, which transfers
the received data to the output lines.

Multiple slaves

There are two ways of connecting multiple slaves to an SPI bus:

1. In general, each
slave will need a
separate SS line. To
talk to a particular
slave, you’ll make
that slave’s SS line
low and keep the rest
of them high (you
don’t want two
slaves activated at
the same time, or
they may both try to
talk on the same
MISO line resulting
in garbled data). Lots of slaves will require lots of SS lines; if you’re running low on outputs,
there are binary decoder chips that can multiply your SS outputs.
1. On the other hand, some parts prefer to be daisy-chained together, with the MISO (output) of
one going to the MOSI (input) of the next. In this case, a single SS line goes to all the slaves.
Once all the data is sent, the SS line is raised, which causes all the chips to be activated
simultaneously. This is often used for daisy-chained shift registers and addressable LED
drivers.

Applications of SPI
Memory: SD Card , MMC , EEPROM , Flash
Sensors: Temperature and Pressure
Control Devices: ADC , DAC , digital POTS and Audio Codec.
Others: Camera Lens Mount, touchscreen, LCD, RTC, video game controller, etc.
Advantages
SPI is very simple to implement and the hardware requirements are not that complex.
Supports full – duplex communication at all times.
Very high speed of data transfer.
No need for individual addresses for slaves as CS or SS is used.
Only one master device is supported and hence there is no chance of con�icts.
Clock from the master is con�gured based on speed of the slave and hence slave
doesn’t have to worry about clock.

Disadvantages

Each additional slave requires an additional dedicated pin on master for CS or SS.
There is no acknowledgement mechanism and hence there is no con�rmation of receipt
of data.
Slowest device determines the speed of transfer. There are no o�cial standards and hence often used in
application specific implementations.
There is no flow control.
3.2.3 UART: Universal Asynchronous Reception and transmission.

Remember when printers, mice, and modems had thick cables with those huge clunky connectors? The ones
that literally had to be screwed into your computer? Those devices were probably using UARTs to
communicate with your computer. While USB has almost completely replaced those old cables and connectors,
UARTs are definitely not a thing of the past. You’ll find UARTs being used in many DIY electronics projects
to connect GPS modules, Bluetooth modules, and RFID card reader modules to your Raspberry Pi, Arduino, or
other microcontrollers.
UART stands for Universal Asynchronous Receiver/Transmitter. It’s not a Communication protocol like SPI
and I2C, but a physical circuit in a microcontroller, or a stand-alone IC.

A UART’s main purpose is to transmit and receive serial data.

One of the best things about UART is that it only uses two wires to transmit data between devices. The
principles behind UART are easy to understand, but if you haven’t read part one of this series, Basics of the
SPI Communication Protocol, that might be a good place to start.

INTRODUCTION TO UART COMMUNICATION

In UART communication, two UARTs communicate directly with each other. The transmitting UART
converts parallel data from a controlling device like a CPU into serial form, transmits it in serial to the
receiving UART, which then converts the serial data back into parallel data for the receiving device. Only two
wires are needed to transmit data between two UARTs. Data flows from the Tx pin of the transmitting UART
to the Rx pin of the receiving UART:
UARTs transmit data asynchronously, which means there is no clock signal to synchronize the output of bits
from the transmitting UART to the sampling of bits by the receiving UART. Instead of a clock signal, the
transmitting UART adds start and stop bits to the data packet being transferred. These bits define the beginning
and end of the data packet so the receiving UART knows when to start reading the bits.

When the receiving UART detects a start bit, it starts to read the incoming bits at a specific frequency known
as the baud rate. Baud rate is a measure of the speed of data transfer, expressed in bits per second (bps). Both
UARTs must operate at about the same baud rate. The baud rate between the transmitting and receiving UARTs
can only differ by about 10% before the timing of bits gets too far off.

Both UARTs must also must be configured to transmit and receive the same data packet structure.

HOW UART WORKS

The UART that is going to transmit data receives the data from a data bus. The data bus is used to send data to
the UART by another device like a CPU, memory, or microcontroller. Data is transferred from the data bus to
the transmitting UART in parallel form. After the transmitting UART gets the parallel data from the data bus, it
adds a start bit, a parity bit, and a stop bit, creating the data packet. Next, the data packet is output serially, bit
by bit at the Tx pin. The receiving UART reads the data packet bit by bit at its Rx pin. The receiving UART
then converts the data back into parallel form and removes the start bit, parity bit, and stop bits. Finally, the
receiving UART transfers the data packet in parallel to the data bus on the receiving end:
UART transmitted data is organized into packets. Each packet contains 1 start bit, 5 to 9 data bits (depending
on the UART), an optional parity bit, and 1 or 2 stop bits:

START BIT

The UART data transmission line is normally held at a high voltage level when it’s not transmitting data. To
start the transfer of data, the transmitting UART pulls the transmission line from high to low for one clock
cycle. When the receiving UART detects the high to low voltage transition, it begins reading the bits in the
data frame at the frequency of the baud rate.

DATA FRAME

The data frame contains the actual data being transferred. It can be
5 bits up to 8 bits long if a parity bit is used. If no parity bit is used,
the data frame can be 9 bits long. In most cases, the data is sent
with the least significant bit first.

STEPS OF UART TRANSMISSION


1. The transmitting UART receives data in parallel from the data bus:
2. The transmitting UART adds the start bit, parity bit, and the stop bit(s) to the data frame:

3. The entire packet is sent serially from the transmitting UART to the receiving UART. The receiving
UART samples the data line at the pre-configured baud rate:

4. The receiving UART discards the start bit, parity bit, and
stop bit from the data frame:

5. The receiving UART converts the serial data back into parallel and
transfers it to the data bus on the receiving end:
ADVANTAGES AND DISADVANTAGES OF UARTS
No communication protocol is perfect, but UARTs are pretty good at what they do. Here are some pros and
cons to help you decide whether or not they fit the needs of your project:

ADVANTAGES
Only uses two wires
No clock signal is necessary
Has a parity bit to allow for error checking
The structure of the data packet can be changed as long as both sides are set up for it
Well documented and widely used method
DISADVANTAGES
The size of the data frame is limited to a maximum of 9 bits
Doesn’t support multiple slave or multiple master systems
The baud rates of each UART must be within 10% of each other

External Interfaces:

1. RS-232: Recommended standard 232.

Officially, the RS232 standard is called EIA/TIA – 232 and is defined as the interface between a DTE and a
DCE devices employing serial binary data interchange. RS232 is considered to be a appropriate standard. This
is because RS232 ensures that there is no conflict between the DTE and DCE devices by specifying:

 Electrical Specifications
 Mechanical Specifications
 Functional Specifications and
 Procedural Specifications

 Simple analog communication over the telephone wires to the typical USB cables for data exchange,
we surely have come a long way in the field of communication. RS232 was the first milestone reached
in this journey. It was a standard for electromechanical typewriters and modems for digital data
exchange introduced in 1962 by the Radio Sector of EIA. It made the data exchange more reliable over
analog channel. The standard defined voltage levels that made it immune to noise disturbances and
reduced the error in data exchange.
 As the technology was growing many electronic devices were being developed during this time like
computers, printers, test instrument etc. There came a time where manufacturers felt the need to
exchange information between these electronic devices. For example data exchange between a
computer and a printer or two computers. But there was no standard or method to accomplish this
task. RS232 was the only available standard at the time which was used for data exchange. So, they
thought of adopting this standard in electronic devices for digital data exchange. But the standard was
unable to fulfill the requirements as it was developed specifically for modem and teletypewriter. To
overcome this problem, designers started implementing an RS232 interface compatible to their
equipments. Like a computer of HP will only be able to use HP peripheral devices. Because of this the
market was flooded with different manufactures with their own standards for their devices. This led to
the common problems like non-standard pin assignment of circuits on connectors, and incorrect or
missing control signals. The lack of adherence to the standard produced a thriving industry of
breakout boxes, patch boxes, test equipments, books and other aids for the connection of dissimilar
equipments. So, to put an end to all theses disparities in equipments, syndicate of manufacturers built a
transmitter that supplied +5V and -5v and labeled them as “RS-232” compatible and they are same till
date. The standard has been revised many times after the initial one and updated by Electronic
industries association. The name of standard was also changed from RS232 to EIA232. The Electronic
Industries Association published three modifications, the most recent being EIA232F introduced in
1997.

 What is RS232 - "RECOMMENDED STANDARD 232"


 RS-232 is a standard communication protocol for linking computer and its peripheral devices to
allow serial data exchange. In simple terms RS232 defines the voltage for the path used for data
exchange between the devices. It specifies common voltage and signal level, common pin wire
configuration and minimum, amount of control signals. As mentioned above this standard was
designed with specification for electromechanically teletypewriter and modem system and did
not define elements such as character encoding, framing of characters, error detection protocols etc
that are essential features when data transfer takes place between a computer and a printer. Without
which it could not be adopted to transfer data between a computer and a printer. To overcome this
problem a single integrated circuit called as UART known as universal asynchronous
receiver/transmitter is used in conjunction with RS232.
 A standard definition was given by EIA to define RS232 as “an interface between Data terminal
equipment and Data communication equipment”. A typical RS232 system is shown below.
 Fig. 2: Image Explaining a Typical RS232 System

 DTE-A DTE stands for data terminal equipment is an end instrument that convert user information

into signals or reconverts the receive signal. It is a functional unit of station that serves as data source

or data sink and provides for communication control function according to the link protocol. A male

connector is used in DTE and has pin out configuration.


 DCE-A DCE stands for data communication equipments. It sits between the DTE and data
transmission circuit for example modem. A DCE device uses a female connector which has holes on
the surface to hold male connector.
 A minimum of three signals are required for communication between a DTE and a DCE devices.
These signals are a transmission line, a reception line and ground. These two devices communicate
with each other by handshaking. It allows a DTE and a DCE device system to acknowledge each other
before sending the data.

The RS232 is a communication cable, generally used to transfer and receive the serial data between two
devices This cable supports both synchronous and asynchronous data transmissions. RS 232 cable is used in
many devices in the industries and it is used to find the difference between two signal levels like logic 0 and
logic 1. The logic 0 is denoted with the +12V and logic 1 is denoted with the -12V. This cable works at
different baud rates, such as 4,800 bits/sec and 9,600 bits/sec. The RS232 consists of two terminal devices,
namely DTE and DCE. These two devices
sends and receives the signals. In present
days, most of the PCs include two serial
ports and one parallel port. These ports
are used to communicate with external
devices.

A serial port sends and receives data one


bit at a time over one wire very slowly. In the same way the parallel port also sends and receives the data over
eight separate wires, and these ports are generally used to connect a printer to a personal computer. The most
of the serial cable connectors are DB-9 (9-pin connector) and B-25 (25-pin connector). These cables may be
male or female type. Nowadays, most of the PCs use DB9 cable for the exchange of asynchronous data. The
maximum size of RS232 cable is 50feet.
RS232 Interfacing to Microcontroller using Max 232

The block diagram of RS232 interfacing with the


microcontroller using MAX232 is shown above.In this,
MAX 232 acts as a buffer driver for the processor. It
receives the typical logic values of 0 and 5 volts and
alters them to the RS232 standard of +10 and -10v.
Some Microcontrollers are built in serial ports which
permit for direct connection with the RS232 serial port
of the computer. However, many microcontrollers give
a 0 to 5volts o/p and need an intermediate buffer to
convert the volts from 0 to 5v to +10 and -10 volts required by the RS232.

Features of Max232 IC

Input supply voltage of 5V.

Input voltage levels compatible with TTL standard.

Output voltage levels compatible with RS 232 standard.

Low input current of 0.1microAmpere and output current of 24mA.

It operates in a temperature range of -40 degree Celsius to +85 degree Celsius

Application of Max 232

Typical applications of Max232 involve modems, computers, RS232 systems and terminals. For a
typical working application involving Max 232 as a intermediate between the Microcontroller and the
RS 232 connected to the Computer, one of the transmitter input pins receive TTL input from the
Microcontroller and the capacitor arrangement obtains the +/-10V signal which is applied to the
corresponding transmitter output pin, given to the RS232 port.

The receiver input pin receives 232 standard input from the RS232 port and accordingly the
corresponding receiver output pin gives the TTL standard output to the Microcontroller. Thus the
Max 232 IC can be used as an intermediate connection between Microcontroller and a Computer.
RS232 Pinout

Below is the pinout of a typical standard male 9-pin RS232 connector, this

connector type is also referred to as a DB9 connector.

A computer's serial COM port (DTE) is usually a male port as shown below, and

any peripheral devices you connect to this port usually has a female connector

(DCE).

This table shows the pin numbers with signal names and the signal direction.

Pin Signal Signal Name DTE Signal direction


1 DCD Data Carrier Detect In
2 RXD Receive Data In
3 TXD Transmit Data Out
4 DTR Data Terminal Ready Out
5 GND Ground -
6 DSR Data Set Ready In
7 RTS Request to Send Out
8 CTS Clear to Send In
9 RI Ring Indicator In
2. USB: Universal Serial Bus

 A Universal Serial Bus (USB) is a common interface that enables communication between
devices and a host controller such as a personal computer (PC). It connects peripheral devices
such as digital cameras, mice, keyboards, printers, scanners, media devices, external hard drives
and flash drives.USB 1.x, USB 2.0,USB 3.x

USB 1.0 USB 2.0 USB 2.0 USB 3.0 USB 3.1/3.2
1996 2001 Revised 2011 2014/2017
Receptacle
s
1.25 GB/s
187.5 kB/s 625 MB/s
(sockets) 60 MB/s 2.5 GB/s
1.5 MB/s (SuperSpeed)
(SuperSpeed+

USB:

USB 0.8 December 1994 Pre-release


USB 0.9 April 1995 Pre-release
USB 0.99 August 1995 Pre-release
USB 1.0- November
Release Candidate
RC 1995
Full Speed
USB 1.0 January 1996
(12 Mbit/s)
Full Speed
USB 1.1 August 1998
(12 Mbit/s)[31]
High Speed
USB 2.0 April 2000
(480 Mbit/s)
November Also referred to as USB 3.1 Gen 1[27] and USB 3.2
USB 3.0 SuperSpeed (5 Gbit/s)
2008 Gen 1x1
SuperSpeed+ Also referred to as USB 3.1 Gen 2[27] and USB 3.2
USB 3.1 July 2013
(10 Gbit/s) Gen 2x1
September SuperSpeed+ Includes new USB 3.2 Gen 1x2 and USB 3.2 Gen 2x2
USB 3.2
2017 (20 Gbit/s) multi-link modes[

Standard A and B USB connectors


Because of all these reasons, two USB connectors have been defined for basic use, the USB A connector which
must be used on devices which provide power (mostly computers), and the USB B connector used on devices
which receive power like most peripheral devices.

USB A connector USB B connector

In the standard USB A and B connectors specified in the USB 1.1 and USB 2.0 specification, four pins are
defined. Two pins are used for power and two pins are used for differential data transmission. If you look
carefully at the connector you will see that the pins for the power connection (pin 1 and 4) are slightly longer.
This is done on purpose to first connect the power supply when connecting a USB device, and only afterwards
establish the data connection. With this sequence the chance that the driver or receiver ports of the data
connection receive awkward and possible dangerous voltages is lowered substantially.

Standard USB A and B connector pin names


Pin Name Color Function

1 Vcc Red +5V supply voltage


2 D- White Data- signal line
3 D+ Green Data+ signal line
4 GND Black Supply ground

Mini USB A and B connectors


The good thing of a USB connector standard is that it is possible to design devices without need to think how
that device should be connected to other devices. The USB A and B connectors proofed their usability with
devices like printers, modems and scanners, but when the faster USB 2.0 was released and USB became not
only a way to connect slow and bulky equipment but also faster and smaller devices like photo camera's and
mobile telephones, especially the standard USB B connector was just too big to fit nicely on these smaller
equipment. An update to the USB 2.0 specification was posted with the name Mini-B connector engineering
change notice which defined a smaller version of the B connector. There has also existed a mini USB A
connector for some time, but as the USB A connector is used on the power sourcing side—mostly a larger
piece of equipment like a computer—that connector was withdrawn from the standard and no new devices will
receive certification any more if they contain such a connector. In practice you won't find the mini USB A
connector any more.

Mini USB A connector Mini USB B connector

Besides the size, the main difference between the standard USB A and B connectors and the mini
USB A and B versions is the extra pin which is called ID. In the mini connector series this pin is
normally not connected. It has been added for future enhancements of the USB standard.

Mini USB A and B connector pin names

Pin Name Color Function

1 Vcc Red +5V supply voltage


2 D- White Data- signal line
3 D+ Green Data+ signal line
4 ID – not connected
5 GND Black Supply ground

Micro USB AB and B connectors


In the modern world small is never small enough and the mini USB B connector soon was too large for new
equipment like cell phones. Therefore in January 2007 the micro USB connector was announced which could
be easier integrated in thin devices than the mini USB version. Although the micro USB connector is much
thinner than its mini USB brother, it has been especially designed for rough use and the connector is specified
for at least 10000 connect/disconnect cycles. One of the reasons is that with mobile devices like cell phones,
PDA's and smartphones the number of mate cycles will be significantly higher than with static equipment like
printers and mice. Furthermore the micro USB connector is becoming the de facto standard to charge mobile
devices and its use will therefore be even more widespread than of its mini USB counterpart.

In the original USB specification there was a strict separation between the host (mostly a computer) which acts
as a master device, and the peripherals which have only slave functionality. As mobile devices get smart and
often run their own operating system, the separation between the two types of devices has vanished. When
connected to a PC a smartphone may be acting as a slave, but it could also be connected to a photo printer
directly to print pictures made with the phone. In that case the phone switches from its slave role to a master.
To allow this an extension to the USB 2.0 specification has been written which is called USB On-The-Go or
more often USB OTG. This supplement provides means for easy switching between the master and slave role
of a device.

Because most small devices which can both act as a master and a slave only have one USB connector,
additions to the connector definition were necessary to allow a role change with only one type of
cable. This is where the mini USB AB and later the micro USB AB connector are defined for. The
mini USB AB connector is now officially deprecated, but the micro USB AB connector is replacing
its place rapidly. Countries like China are even considering to make this micro USB AB connector
mandatory on all new cell phones sold. In this micro USB AB connector the ID pin is used to signal
the master of slave function.

Micro USB AB connector Micro USB B connector

The pin numbering for the micro USB connectors is the same as for the mini USB connectors. The
only difference is that for the micro USB AB connector the ID pin now has a function assigned to it.

Micro USB AB and B connector pin names

Pin Name Color Function

1 Vcc Red +5V supply voltage


2 D- White Data- signal line
3 D+ Green Data+ signal line
not connected: works as B connector
4 ID – connected to GND: works as A connector
5 GND Black Supply ground
PREVIOUS YEARS UNIVERSITY QESTIONS

1. A) Draw the circuit of TTL to RS232 and explain the necessity of this interface.
B) Distinguish between synchronous and asynchronous serial data transmission
techniques. Discuss the advantages and disadvantages.

2.Explain the need for RS232C interface. Explain serial communication standards with respect to voltage
levels.
3.What are the different data rats offered by different USB versions
4. How SPI Master can connect with different slave devices
5. Explain difference between Synchronous and asynchronous transmission
6. Explain different transmission modes.

Das könnte Ihnen auch gefallen