SPI
Start with the Definition:
SPI (Serial Peripheral Interface) is a full-duplex, synchronous, serial communication protocol used
to transfer data between a master and one or more slave devices.
It is commonly used for high-speed communication with peripherals like SD cards, flash memory,
sensors, and displays.
Mention the Key Features:
• Full duplex communication (data sent and received simultaneously)
• Faster than I2C (because it’s simpler and uses more lines)
• Uses 4 main lines:
1. MOSI – Master Out Slave In
2. MISO – Master In Slave Out
3. SCLK – Serial Clock (generated by master)
4. SS / CS – Slave Select / Chip Select (active LOW)
SPI Frame Format (Byte Transfer Explanation):
[SS LOW] → [SCLK begins] → [MOSI sends data bit-by-bit] ← [MISO receives data bit-by-bit] → [SS
HIGH]
• When SS (Slave Select) is pulled LOW, the communication with the selected slave begins.
• Data is shifted out bit-by-bit on the rising or falling edge of the clock.
• Each 8-bit frame is transferred synchronously with the clock.
Full Duplex Operation:
Unlike I2C, SPI supports simultaneous send and receive:
• MOSI: Master sends data to slave
• MISO: Slave sends data back to master
How SPI Works (Step-by-Step):
1. Master sets SS low for the target slave.
2. Master generates clock pulses on SCLK.
3. Master sends data through MOSI.
4. Slave simultaneously sends data through MISO.
5. After transmission, SS is set high, ending communication.
Example (If you used it in your project):
In my project, I used SPI to interface an SD card with the microcontroller for data logging.
The master (MCU) sends read/write commands over MOSI, and receives data over MISO while
controlling the SD card via CS.
Summary Statement for Interview:
“SPI is a high-speed, full-duplex, synchronous protocol used for short-range communication between
a master and slaves using four wires. It's ideal for fast data transfers and is simpler than I2C in terms
of protocol structure but requires more pins.”