Introduction I2c and SPI
Introduction I2c and SPI
26/09/14
Introduction to IC
and SPI protocols
IC vs SPI
Today, at the low end of the communication protocols,
we find IC (for Inter-Integrated Circuit, protocol) and
SPI (for Serial Peripheral Interface). Both protocols
are well-suited for communications between
integrated circuits, for slow communication with onboard peripherals. At the roots of these two popular
protocols we find two major companies Philips for
IC and Motorola for SPI and two different histories
about why, when and how the protocols were created.
The IC bus was developed in 1982; its original
purpose was to provide an easy way to connect a CPU
to peripherals chips in a TV set. Peripheral devices in
embedded systems are often connected to the
microcontroller as memory-mapped I/O devices. One
common way to do this is connecting the peripherals
to the microcontroller parallel address and data
busses. This results in lots of wiring on the PCB
(printed circuit board) and additional glue logic to
decode the address bus on which all the peripherals
are connected. In order to spare microcontroller pins,
additional logic and make the PCBs simpler in order
words, to lower the costs Philips labs in Eindhoven
(The Netherlands) invented the Inter-Integrated
Circuit, IIC or IC protocol that only requires 2 wires for
connecting all the peripheral to a microcontroller. The
original specification defined a bus speed of 100 kbps
(kilo bits per second). The specification was reviewed
several times, notably introducing the 400 kbps speed
in 1995 and since 1998, 3.4 Mbps for even faster
http://www.byteparadigm.com/applications/introduction-to-i2c-and-spi-protocols/
1 / 14
Introduction to IC and SPI protocols Byte Paradigm Speed up embedded system verication
26/09/14
peripherals.
It seems the Serial Peripheral Protocol (SPI) was first
introduced with the first microcontroller deriving from
the same architecture as the popular Motorola 68000
microprocessor, announced in 1979. SPI defined the
external microcontroller bus, used to connect the
microcontroller peripherals with 4 wires. Unlike IC, it
is hard to find a formal separate specification of the
SPI bus for a detailed official description, one has to
read the microcontrollers data sheets and associated
application notes.
SPI
SPI is quite straightforward it defines features any
digital electronic engineer would think of if it were to
quickly define a way to communicate between 2 digital
devices. SPI is a protocol on 4 signal lines (please
refer to figure 1):
A clock signal named SCLK, sent from the bus
master to all slaves; all the SPI signals are
synchronous to this clock signal;
A slave select signal for each slave, SSn, used to
select the slave the master communicates with;
A data line from the master to the slaves, named
MOSI (Master Out-Slave In)
A data line from the slaves to the master, named
MISO (Master In-Slave Out).
2 / 14
Introduction to IC and SPI protocols Byte Paradigm Speed up embedded system verication
26/09/14
3 / 14
Introduction to IC and SPI protocols Byte Paradigm Speed up embedded system verication
26/09/14
IC
IC is a multi-master protocol that uses 2 signal lines.
The two IC signals are called serial data (SDA) and
serial clock (SCL). There is no need of chip select
(slave select) or arbitration logic. Virtually any number
of slaves and any number of masters can be
connected onto these 2 signal lines and communicate
between each other using a protocol that defines:
7-bits slave addresses: each device connected to the
bus has got such a unique address;
data divided into 8-bit bytes
a few control bits for controlling the communication
start, end, direction and for an acknowledgment
mechanism.
The data rate has to be chosen between 100 kbps,
400 kbps and 3.4 Mbps, respectively called standard
mode, fast mode and high speed mode. Some IC
variants include 10 kbps (low speed mode) and 1
Mbps (fast mode +) as valid speeds.
Physically, the IC bus consists of the 2 active wires
SDA and SCL and a ground connection (refer to figure
4). The active wires are both bi-directional. The I2C
protocol specification states that the IC that initiates a
data transfer on the bus is considered the Bus Master.
Consequently, at that time, all the other ICs are
regarded to be Bus Slaves.
http://www.byteparadigm.com/applications/introduction-to-i2c-and-spi-protocols/
4 / 14
Introduction to IC and SPI protocols Byte Paradigm Speed up embedded system verication
26/09/14
5 / 14
Introduction to IC and SPI protocols Byte Paradigm Speed up embedded system verication
26/09/14
6 / 14
Introduction to IC and SPI protocols Byte Paradigm Speed up embedded system verication
26/09/14
7 / 14
Introduction to IC and SPI protocols Byte Paradigm Speed up embedded system verication
26/09/14
- Clock stretching
In an IC communication the master device determines
the clock speed. The SCL signal is an explicit clock
signal on which the communication synchronizes.
However, there are situations where an IC slave is not
able to co-operate with the clock speed given by the
master and needs to slow down a little. This is done by
a mechanism referred to as clock stretching and is
made possible by the particular open-drain / pull-up
structure of a IC bus line.
An IC slave is allowed to hold down the clock if it
needs to reduce the bus speed. The master on the
other hand is required to read back the clock signal
after releasing it to high state and wait until the line has
actually gone high.
- High speed mode
Fundamentally, the use of pull-ups to set a logic one
limits the maximum speed of the bus. This may be a
http://www.byteparadigm.com/applications/introduction-to-i2c-and-spi-protocols/
8 / 14
Introduction to IC and SPI protocols Byte Paradigm Speed up embedded system verication
26/09/14
IC vs SPI: is there a
winner?
Lets compare IC and SPI on several key protocol
aspects:
- Bus topology / routing / resources:
IC needs 2 lines and thats it, while SPI formally
defines at least 4 signals and more, if you add slaves.
Some unofficial SPI variants only need 3 wires, that is
a SCLK, SS and a bi-directional MISO/MOSI line. Still,
this implementation would require one SS line per
slave. SPI requires additional work, logic and/or pins if
a multi-master architecture has to be built on SPI. The
only problem IC when building a system is a limited
device address space on 7 bits, overcome with the 10bits extension.
From this point of view, IC is a clear winner over SPI in
sparing pins, board routing and how easy it is to build
an IC network.
- Throughput / Speed:
If data must be transferred at high speed, SPI is
clearly the protocol of choice, over IC. SPI is fullduplex; IC is not. SPI does not define any speed limit;
implementations often go over 10 Mbps. IC is limited
to 1Mbps in Fast Mode+ and to 3.4 Mbps in High
Speed Mode this last one requiring specific I/O
buffers, not always easily available.
- Elegance:
It is often said that IC is much more elegant than SPI,
and that this last one is a very rough (if not dumb)
protocol. Actually, we tend to think the two protocols are
http://www.byteparadigm.com/applications/introduction-to-i2c-and-spi-protocols/
9 / 14
Introduction to IC and SPI protocols Byte Paradigm Speed up embedded system verication
26/09/14
Conclusions.
In the world of communication protocols, IC and SPI
are often considered as little communication
protocols compared to Ethernet, USB, SATA, PCIExpress and others, that present throughput in the
x100 megabit per second range if not gigabit per
second. Though, one must not forget what each
protocol is meant for. Ethernet, USB, SATA are meant
for outside the box communications and data
exchanges between whole systems. When there is a
need to implement a communication between
integrated circuit such as a microcontroller and a
set of relatively slow peripheral, there is no point at
using any excessively complex protocols. There, IC
and SPI perfectly fit the bill and have become so
popular that it is very likely that any embedded
system engineer will use them during his/her career.
Back to Top
http://www.byteparadigm.com/applications/introduction-to-i2c-and-spi-protocols/
10 / 14
Introduction to IC and SPI protocols Byte Paradigm Speed up embedded system verication
26/09/14
Submit
http://www.byteparadigm.com/applications/introduction-to-i2c-and-spi-protocols/
11 / 14
Introduction to IC and SPI protocols Byte Paradigm Speed up embedded system verication
26/09/14
12 / 14
Introduction to IC and SPI protocols Byte Paradigm Speed up embedded system verication
26/09/14
Legal information
Byte Paradigm sprl
Reg nr: BE0873.279.914
Bank information ING Belgium
Avenue des anciens combattants 17, 1140 Evere,
Belgium
IBAN : BE12310198559692
SWIFT/BIC : BBRUBEBB
General Conditions
Download our general conditions of sales below:
General Sales Conditions (PDF)
Byte Paradigm offers custom design services - please
download our general conditions from the link below:
General Conditions for Design Services (PDF)
Address
Byte Paradigm
Avenue Molire, 18
B-1300 Wavre - BELGIUM
Tel: +32 (0)10 844 008
Fax: +32 (0)10 280 223
info@byteparadigm.com
13 / 14
Introduction to IC and SPI protocols Byte Paradigm Speed up embedded system verication
26/09/14
Click here to know more about us, our history and our
future.
Click here receive our newsletter
Follow us !
Back to Top
http://www.byteparadigm.com/applications/introduction-to-i2c-and-spi-protocols/
14 / 14