KEMBAR78
Serial Protocols: RS232, I2C, SPI | PDF | Computer Engineering | Physical Layer Protocols
0% found this document useful (0 votes)
56 views9 pages

Serial Protocols: RS232, I2C, SPI

1) Serial communication protocols like I2C, SPI, and RS-232 are used to allow complex sensors and devices to exchange more data than a single bit over a shared set of pins. 2) I2C is a synchronous, half-duplex, master-slave protocol that uses a shared clock and data line. It requires less lines than SPI but is slower. SPI is a synchronous, full-duplex, master-slave protocol that uses separate clock, data input, and data output lines, allowing it to operate faster than I2C. 3) Common applications of I2C include controlling small displays, reading sensors, and power management. SPI is commonly used for high-speed

Uploaded by

hoxojew752
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views9 pages

Serial Protocols: RS232, I2C, SPI

1) Serial communication protocols like I2C, SPI, and RS-232 are used to allow complex sensors and devices to exchange more data than a single bit over a shared set of pins. 2) I2C is a synchronous, half-duplex, master-slave protocol that uses a shared clock and data line. It requires less lines than SPI but is slower. SPI is a synchronous, full-duplex, master-slave protocol that uses separate clock, data input, and data output lines, allowing it to operate faster than I2C. 3) Common applications of I2C include controlling small displays, reading sensors, and power management. SPI is commonly used for high-speed

Uploaded by

hoxojew752
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

27/04/23

Serial protocols: RS232,


I2C and SPI

.DIEM
INTERNET OF THINGS

Introduction
• Complex sensors and other devices need to exchange
more data than a single bit
• Example: an accelerometer provides three acceleration
values for the three coordinate axes
• Usually there are also several configuration
parameters (e.g. for the accelerometer, the
frequency of acquisition, maximum g acc.)
• It would not be possible to have a separate pin for all
the information that must be exchanged!

1
27/04/23

Serial protocols

The solution: serial communication A protocol is needed to define the


details of the communication:
The information is divided into bits How is a communication started?
The bits are transmitted sequentially over the How do we know when the next bit arrives?
same line How do we know for whom is the
communication (in case multiple devices are
listening to the same line)?
How a device is physically connected to the line?
What are the voltage levels used?
… and so on

In Half-duplex
protocols, the same Only one
communication
physical line is used for at a time may
transmitting and happen
receiving
Half-duplex vs
Full-duplex In Full-duplex both parties can
protocols, separate lines send data at the
same time
are used for faster, but
transmitting and requires more
receiving hardware lines

2
27/04/23

Synchronous vsAsynchronous
• In Synchronous protocols, a clock signal is used to delimit bits
• Requires one more line
• Problems with long lines (clock skew)
• Faster

• In Asynchronous protocols, the parties agree on the duration


of a bit (bit rate, baud rate)
• Since the clocks of the two devices are never exactly identical,
Synchronous vs problems when transmitting long messages (some kind of
synchronization mechanism must be added to the protocol)
Asynchronous

3
27/04/23

Master-Slave vs Peer-to-
peer
• In Master-Slave protocol, only
one device (the master) can start
the communication
• Usually the master is the CPU/MCU
• In Peer-to-peer protocols, any
device can start the
communication
• A mechanism may be needed to
arbitrate the case when more
devices want to communicate at the
same time

Dedicated vsShared
• Some protocols require a separate set of communication
lines (dedicated lines) for each pair of devices that must
communicate
• Also called one-to-one protocols
• Other protocols allow for a single set of lines to be shared
by several devices (a bus)
• In this case, the protocol must include a way to
select the intended recipient of the
communication

4
27/04/23

Common protocols:RS232
• Asynchronous, full duplex, peer-to-peer, with dedicated lines
• Only requires two lines: Tx (transmit) and Rx (receive), plus the common ground
• The true RS232 protocol requires +/- 9V voltages; in embedded systems it is more
common to use 0-5V voltages
• Max speed depending on the distance and the type of cable, 115200 bit/s (but usually
lower values are much more common, such as 9600 bit/s)

RS-232
transmission
example

5
27/04/23

Common protocols: I2C


• Inter-Integrated Circuit, introduced by Philips
• Synchronous, half-duplex, master-slave with shared lines
• Each slave requires a separate “address”, that is transmitted on the line by the master to
select the slave
• SDA=Serial Data, SCL=Serial Clock
• Requires less lines than SPI, but it is slower even when using the same clock rate
• Half duplex
• Overhead for transmission of the address
• Max speed=3.4 Mbit/s

• Transmitter/receiver differs from master/slave


• Master initiates transactions
I2C • Slave responds
• Transmitter sets data on SDA line, slave acks
transaction • For a read, slave is transmitter
• For a write, master is transmitter

12

6
27/04/23

• Data is always sampled on the rising clock edge


• Address is 7 bits (low-speed)
• An 8-th bit (MSB) indicated read or write
I2C address • High (1) for read

transmission • Low (0) for write


• Addresses assigned by Philips/NXP
• For a fee
• Was covered by patent (now expired)

13

I2C is appropriate for peripherals where simplicity and low manufacturing


cost are more important than speed.
Common applications of the I2C bus are:
• Accessing real-time clocks and NVRAM chips that keep user settings.
• Accessing low-speed DACs and ADCs.
• Changing backlight, contrast, hue, color balance settings… in monitors
I2 C • Changing sound volume in intelligent speakers.

Applications • Controlling small LCD or OLED displays.


• Reading hardware monitors and diagnostic sensors, e.g. a fan's speed.
• Turning on and off the power supply of system components.
A particular strength of I2C is the capability of a microcontroller to control a
network of device chips with just two general-purpose I/O pins and
software.

7
27/04/23

Common protocols:SPI
• Serial Peripheral Interface, introduced by Motorola
• Synchronous, full-duplex, master-slave with shared lines
• Each slave requires a separate “slave select” (SS or CS) signal
• MISO = Master Input Slave Output
• MOSI = Master Output, Slave Input
• Max speed= 50 Mbit/s

• Master mode
• Only a master SPI initiates a transmission
• Data is shifted out via Master Out Slave In (MOSI) line
• Data is shifted in via Master In Slave Out (MISO) line
• Transmission ends after 8 cycles of serial clock (SCLK)
• Slave Mode
• Transfer synchronized to serial clock (SCLK) from Master
• Data is shifted in via the Master Out Slave In (MOSI) line
• Data is shifted out via the Master In Slave Out (MISO) line
SPI Modes

8
27/04/23

• SPI has 4 different ways of interpreting


the clock
• The master and the slave must use the same
way
Common
protocols:
SPI

You might also like