SPI(Serial Peripheral Interface):-
SPI (Serial Peripheral Interface) bus, which is commonly used for communication between integrated circuits or sensors .It is a serial master-slave Synchronous Protocol . It comes built in on many microcontrollers and SOC. The SPI serial bus was originally established by Motorola. Today, it is one of the most common communication buses used by integrated circuit manufactures for device to processor or FPGA control. Examples include ADCs, DACs, sensors, and board-only products. I
Although it is not regulated as a standard by IEEE or another organization, most devices adhere to common set of rules described .
SPI is a synchronous serial data link that operates in full duplex. That is, signals carrying data go in both directions simultaneously. Devices communicate using a master/slave protocol, in which the
master starts the data frame. When the master generates a clock then selects a slave device, data may be transferred in either or both directions simultaneously. It is up to the master and slave devices to know whether a received byte is meaningful. This may require a device to discard the received byte in a transmit only” frame or generate a dummy byte for a “receive only” frame.
It uses four wires Serial ClocK (SCLK), Chip Select (CS), Master Out Slave In (MOSI), Master In Slave Out (MISO).
Basic Connections :-
The four typical SPI signals include:
clock (SCLK) – This signal is generated by the Master. Other signals in the transmission change based on the timing of edges from this clock.
master data output, slave data input (MOSI) – This line is the output from the Master to the slave. Transmits bit-by-bit synchronized with Master clock edges.
master data input, slave data output (MISO) – This line is the output from all the slaves connected. Transmits bit-by-bit from the slave synchronized with Master clock edges.
chip select (CS) or slave select (SS) – This is a bank of signals where each line goes to individual slaves in the system. One line is asserted at a time to enable communicate with the corresponding slave.
MOSI is used for shifting data into the slave device, and MISO is used for shifting data out of the slave device. Because the SPI bus has dedicated wires for transmitting and receiving data, it can operate in full-duplex mode, unlike the I 2C bus. The typical speed of
operation of SPI is in the low-megahertz range, unlike the mid-kilohertz range on I2C, so the former yields higher throughput.
SPI peripherals available in the market today include Radio Frequency (RF) chips, smart card interfaces, EEPROMs, RTCs, touch sensors, and ADC
Basic Transmission Step-by-Step
1. The Master drives a particular SS line low to initiate communication with the corresponding slave.
2. Once the selected SS is low, one edge (rising or falling) of the SCLK signals the devices (Master and Slave) to toggle the MOSI and MISO to the correct bit of data being transmitted.
3. The other edge of the SCLK line (rising or falling) signals the devices to register the bits on the MOSI and MISO, effectively reading the bit into the device.
4. The transmission continues in this fashion until the devices have exchanged the specified number of bits (usually 8,16, or 32)
5. After the transmission is complete the Master pulls the SS line for the slave back high and either goes to another slave on the network or reinitiates the transmission with the same slave by
pulling the corresponding1 SS line back to low.