Serial Peripheral
Interface
• What is the SPI serial interface?
• SPI Specification
• Data Transmission
• SPI Modes
• Mode 0
• Mode 1
• Mode 2
• Mode 3
• Daisy Chain
• How Daisy Chaining Is Accomplished?
• Advantages of SPI
• Disadvantages of SPI
• Applications
What is the SPI serial interface?
•Serial Peripheral Interface is an interface
bus commonly used to transmit and
receive the data between
microcontrollers and small peripherals
such as shift registers, sensors, displays,
flash memory, etc
SPI Specification
• SPI needs 4 wires at least. But some of the recent day devices support
3 pin mode and 4pin modes also.
[Link] – Master Out Slave In
[Link] – Master In Slave Out
[Link] – Serial Clock
[Link]/CS/CE – Salve Select/Chip
Select/Chip Enable
Modes of Operation
SPI Bus 3-Wire
Multi-IO Configurations
Daisy-chain configuration
multi-slave configuration, the
number of GPIOs needed increases
tremendously.
Multi-slave switches using a serial-
to-parallel converter
Advantages of SPI
• It’s way faster than asynchronous serial communication and I2C (almost
twice as fast).
• No start and stop bits, so the data can be streamed continuously without
interruption.
• No slave addressing mechanism like I2C.
• It has separate MISO and MOSI lines, so data can be sent and received at
the same time (Full duplex).
• Not Limited to 8-bit data.
• The received hardware (slave) can be a simple shift register.
• It supports multiple slave devices.
Disadvantages of SPI
• It requires more lines (wires) than other communication methods. (UART and I2C
only require 2 lines).
• There is no acknowledgment to inform that data has been successfully transferred
like I2C and No error detection protocol is defined.
• The communications must be well-defined in advance (you can’t send random
amounts of data whenever you want).
• The master must control all communications (slaves can’t talk directly to each other).
• It usually requires separate CS lines to each peripheral, which can be problematic if
numerous slaves are needed.
• SPI only supports a single master.
• Can be used only from short distances
Applications
SPI is used to talk to a variety of peripherals, such as,
• Sensors: temperature, pressure, ADC, touchscreens, video game controllers
• Control devices: audio codecs, digital potentiometers, DAC
• Camera lenses: Canon EF lens mount
• Communications: Ethernet, USB, USART, CAN, IEEE 802.15.4, IEEE 802.11,
handheld video games
• Memory: flash and EEPROM
• Real-time clocks
• LCD
• Any MMC or SD card