SPI (Serial Peripheral Interface)
is a common serial communication bus used in embedded systems to connect microcontrollers to peripheral devices. It is a synchronous, full-duplex, master-slave based bus.
Primary Topology
It adopts a Star Topology, with single master & multiple slaves, where the master controls individual chip select (CS) lines for each slave.
Here are the key characteristics of the SPI bus:
1. Common Shared Lines
In a multi-device setup, the SPI bus shares three main lines across all slave devices:
- SCLK (Serial Clock): Generated by the master to synchronize data transmission.
- MOSI (Master Out Slave In): Data line used for sending data from the master to the slaves.
- MISO (Master Input Slave Output): Data line used for sending data from the slaves back to the master.
2. Device Selection (Unique Lines)
While the data and clock lines are shared, each slave device requires its own unique Chip Select (CS) or Slave Select (SS) line from the master. The master activates a specific device by pulling its dedicated CS line low.
3. Key Features
- Speed: SPI is capable of high-speed data transfer, often operating in the 1-100 Mbit/s range.
- Full-Duplex: Data can be sent and received simultaneously.
- Short Distance: Primarily designed for communication over short distances, typically on the same PCB.
4. Alternative Configurations
- Daisy-Chain: Multiple devices can be connected in a chain, where the MISO of one device connects to the MOSI of the next, requiring only one CS line for all devices.
- Single Slave: If only one device exists, its CS pin can be tied to ground.
5. Common Applications
SPI is widely used for:
- Memory: Flash memory, EEPROM, and SD cards.
- Sensors: Accelerometers, temperature sensors.
- Displays: LCD and OLED panels.
- Converters: Analog-to-digital (ADC) and digital-to-analog (DAC) converters.
