17spi SP
17spi SP
SPI Basics
• The Serial Peripheral Interface (SPI) bus was developed by Motorola
• Full-duplex
• Synchronous
• The SPI bus is commonly used for communication with Flash memory, sensors,
real-time clocks (RTCs), analog-to-digital converters, and more
SPI
Physical Layer
MOSI MOSI
• At the simplest level, SPI CLK CLK
Slave
Master MISO
communications consists of a single MISO CS
CS
bus master connected to a single
bus slave.
The SPI bus specifies four logic signals:
• One device acts as Master and other
as Slave.
• SCLK : Serial Clock (output from master)
• Multiple slave-devices may be
• MOSI : Master Out Slave In (data output
supported through selection with
from master)
individual chip select (CS), • MISO : Master In Slave Out (data output
sometimes called slave select (SS)
from slave)
lines • SS : Slave Select (often active low, output
• Two data transfer lines.
from master to indicate that data is
being sent)
Physical Layer
• At the same time the slave reads the first bit from the
master at MOSI, stores it into memory, and clocks
out its MSB via MISO.
Bit Transfer
cont...
SP
I
• SPI interface allows to transmit and receive data simultaneously on two lines (MOSI
and MISO).
• Clock polarity (CPOL) and clock phase (CPHA) are the main parameters that
define a clock format to be used by the SPI bus.
• Idle (or First) State is 0 so the Polarity =0
Clock Polarity
• SCK(Clock) positive polarity is good when bus master is powered separately as SCK will
not glitch when master is power up/down.
• You select the mode by configuring a bit in a configuring register. Your device
manual will tell you which bit it is
• As for how to configure clock phase and polarity, it depends on the device you are
working with.
• Typically the device has a register with bits corresponding to clock phase and
polarity this bit can be manipulated to bring the device in the desired mode.
Advantages of SPI
3. No Acknowledgement Signal.
I2C SPI
multi slave, multi master multi slave, single master
I2C vs SPI
half duplex communication full duplex communication
2 wire 4 wire
speed varies according to the 5 possibility of speed is above
modes of operation 100MHz
slower than SPI faster than I2C
draws more power draws less power
less expensive than SPI more expensive than I2C
acknowledgement based no acknowledgement
authentication of data receipt
uses frames to separate data of 12-16 bit can also be
messages sent
wire and logic interface with a no pull up register
pull-up register
Thank you!