Monday, February 1, 2016

Serial Peripheral Interface

Serial Peripheral Interface(SPI) is a serial data protocol that is used by microcontrollers and small electronic devices to exchange information.

The Raspberry Pi is equipped with one SPI bus that has 2 chip selects.The SPI bus is a synchronous serial communication interface specification which can be used for communication between Pi and other hardware devices.

The SPI master driver is disabled by default on Raspian.
To enable it, remove the blacklisting for spi-bcm2708 in /etc/modprobe.d/raspi-blacklist.conf, or use raspi-config.

The SPI bus is available on the P1 Header.

SPI Pin Description on Pi Header:

P1-19           MOSI   - Master Out Slave In
P1-21           MISO   - Master In Slave Out
P1-23           SCLK   - Serial CLocK
P1-25           GND    - Ground
P1-24           CE0     - Chip Enable(or Chip Select)
P1-26           CE1     - Chip Enable

There are multiple modes available in SPI. They are:


STANDARD MODE:


In Standard SPI master mode the peripheral implements the standard 3 wire serial protocol (SCLK, MOSI and MISO).


BIDIRECTIONAL MODE:


In bidirectional SPI master mode the same SPI standard is implemented except that a single wire is used for data (MIMO) instead of two as in standard mode (MISO and MOSI).

LOSSI MODE (LOW SPEED SERIAL INTERFACE):


The LoSSI standard allows issuing of commands to peripherals (LCD) and to transfer data to and from them. LoSSI commands and parameters are 8 bits long, but an extra bit is used to indicate whether the byte is a command or parameter/data. This extra bit is set high for a data and low for a command. The resulting 9-bit value is serialized to the output. LoSSI is commonly used with MIPI DBI type C compatible LCD controllers.


TRANSFER MODES:


Polled
Interrupt
DMA

To use SPI, need four pins:

MOSI   - Master Out Slave In
MISO   - Master In Slave Out
SCLK   - Serial CLocK
SS         - Slave Select

There is some variety in how different SPI devices expect the process how data communication works between master and slave to work.
Some require clock line high when not in-use other require low.

Reference : https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md

No comments:

Post a Comment