📊 Protocol View SPI Protocol

SPI Timing Diagram Generator

SPI (Serial Peripheral Interface)

SPI is a full-duplex synchronous serial communication interface developed by Motorola, using four lines (MOSI, MISO, SCK, CS) for high-speed data transmission, commonly used for communication between MCU and peripherals (Flash, SD cards, sensors, etc.).

📌 SPI Key Features

  • Four-wire Communication: MOSI (Master Out Slave In), MISO (Master In Slave Out), SCK (Clock), CS/SS (Chip Select)
  • Full Duplex: Can send and receive data simultaneously
  • High-Speed Transfer: Typically reaches tens of MHz, far exceeding I2C
  • Master-Slave Mode: One master, multiple slaves, selecting slave devices through different CS lines
  • Mode Configuration: Supports 4 modes (CPOL + CPHA combination)
  • MSB First: Data is transferred Most Significant Bit first (bit 15 → bit 0 for 16-bit data)
  • No Acknowledgment: Unlike I2C which requires ACK, simpler transmission

🔄 SPI Timing Waveform

🔧 JSON Editor

📖 SPI Transfer Timing Description

1
CS Pull Low: Master pulls CS low to select target slave device
2
Clock Start (SCK): Master generates clock signal to control data transfer timing
3
Full Duplex Transfer: Each clock cycle, MOSI and MISO transmit data bits simultaneously
4
Data Shift: Usually MSB transmitted first, completing one byte after 8 bits
5
CS Pull High: After transfer complete, CS pulled high to release slave device

⚙️ SPI Four Operating Modes

Mode CPOL CPHA Idle Clock Sample Edge Common Applications
Mode 0 0 0 Low Rising Edge SD cards, most sensors
Mode 1 0 1 Low Falling Edge Some EEPROMs
Mode 2 1 0 High Falling Edge Some LCD displays
Mode 3 1 1 High Rising Edge MMC cards, some ADCs
Note:
  • CPOL (Clock Polarity): Clock polarity, determines idle clock level
  • CPHA (Clock Phase): Clock phase, determines data sampling timing
  • Master and slave devices must use the same SPI mode for proper communication

⚡ SPI vs I2C Comparison

🚀 Speed

SPI: Tens of MHz
I2C: Max 3.4MHz

🔌 Wires

SPI: 4+ wires (each slave needs separate CS)
I2C: 2 wires

📡 Communication

SPI: Full duplex
I2C: Half duplex

🎯 Addressing

SPI: Hardware CS selection
I2C: Address-based