Spi flash signals during normal operation. What is SPI interface

SPI (Serial Peripheral Interface) is a serial, synchronous, full-duplex data transfer standard developed by Motorola to provide easy and inexpensive interfacing of microcontrollers and peripherals. SPI is also sometimes referred to as a four-wire interface. SPI is a synchronous protocol in which any transmission is synchronized to a common clock signal generated by the host (processor). The receiving peripheral (slave) synchronizes the receipt of the bit sequence with the clock signal. Multiple ICs can be connected to a single serial peripheral interface of a master IC. The master selects the slave to transmit by activating the chip select signal on the slave chip. Peripherals not selected by the processor do not participate in the SPI transfer.
SPI uses four digital signals:

  • MOSI or SI - master output, slave input (English Master Out Slave In). Serves to transfer data from the master to the slave;
  • MISO or SO - master input, slave output (English Master In Slave Out). Serves to transfer data from the slave to the master.
  • SCK or SCLK - serial clock signal (eng. Serial CLocK). Serves to transmit a clock signal for slave devices.
  • CS or SS - chip selection, slave selection (English Chip Select, Slave Select). As a rule, the choice of a chip is made by a low logic level.

Depending on the polarity and clock phase combinations, there are four modes of SPI operation.

SPI mode timing diagram
SPI0 mode

SPI1 mode
Active pulse level is high.

SPI2 mode

First snap, then shift.

SPI3 mode
Active pulse level is low.
First shift, then snap.

The table accepts:

  • MSB - most significant bit;
  • LSB is the least significant bit.

The master has to adjust to the mode used by the slave.
When exchanging data via the SPI interface, the microcontroller can operate as a master (Master mode) or as a slave (Slave mode). In this case, the user can set the following parameters:

  • operating mode according to the table;
  • transmission speed;
  • transmission format (from the least significant bit to the most significant or vice versa).

The connection of two microcontrollers according to the structure master - slave via the SPI interface is carried out according to the following scheme.

The SCK, CS pins for the master microcontroller are outputs, and the slave microcontroller are inputs.

Data transfer is carried out as follows. When writing to the SPI data register of the master microcontroller, the clock signal generator of the SPI module is started, and the data begins to be bit-by-bit issued to the MOSI pin and, accordingly, to the MOSI pin of the slave microcontroller. After issuing the last bit of the current byte, the clock signal generator stops with the simultaneous setting of the "End of transmission" flag to "1". If interrupts from the SPI module are supported and enabled, an interrupt request is generated. After that, the master microcontroller can start transmitting the next byte, or, by applying a logic level “1” voltage to the SS input of the slave, put it into the waiting state.

Simultaneously with the transfer of data from the master to the slave, there is a transfer in the opposite direction, provided that a low level voltage is present at the SS input of the slave. Thus, in each shift cycle, data is exchanged between devices. At the end of each cycle, the interrupt flag is set to "1" in both the master microcontroller and the slave. Received bytes are stored in receive buffers for later use.

When receiving data, the received byte must be read from the SPI data register before the last bit of the next byte enters the shift register. Otherwise, the first byte will be lost.

The SS pin is for selecting the active slave and is always an input in Slave mode. Each time the SS pin is energized to logic 1, the SPI module is reset. If the state change of this pin occurs during data transfer, both the reception and transmission will immediately stop, and the transmitted and received bytes will be lost.

If the microcontroller is in Master mode, the direction of data transfer through the SS pin is user-defined. When a pin is configured as an output, it acts as a general purpose pin and does not affect the operation of the SPI module. As a rule, in this case it is used to control the SS pin of the microcontroller operating in Slave mode.

If the pin is configured as an input, it must be energized for the SPI module to function properly. high level. Applying a low level voltage to this input from any external circuit will be perceived by the SPI module as the choice of the microcontroller as a slave (in this case, data will be transferred to it).

An example of using the SPI interface for STM32 microcontrollers is well described in

With ratings from 10 Ohm to 1 MΩ);

  • connecting wires (for example, here is such a good set);
  • personal computer with the Arduino IDE development environment.
  • 1 Description of the serial SPI interface

    SPI - Serial Peripheral Interface or "Serial Peripheral Interface" is a synchronous communication protocol for pairing master device With peripheral devices(slave). The master device is often a microcontroller. Devices communicate over four wires, which is why SPI is sometimes referred to as a "four-wire interface". Here are the tires:

    There are four transmission modes ( SPI_MODE0, SPI_MODE1, SPI_MODE2, SPI_MODE3), due to the combination of the polarity of the clock pulses (we work at the HIGH or LOW level), Clock Polarity, CPOL, and the phase of the clock pulses (synchronization on the leading or trailing edge of the clock pulse), Clock Phase, CPHA.

    The figure explains this table.

    The SPI interface provides several options for connecting slave devices: independent And cascading. With an independent connection to the SPI bus, the master device accesses each slave device individually. With a cascade connection, the slave devices work in turn, as if in a cascade.


    Types of connecting devices to work via the SPI interface: independent and cascade

    2 Implementation of the SPI interface on boards of the Arduino family

    In the Arduino, the SPI interface buses are on specific ports. Each board has its own pin assignment. For convenience, the conclusions are duplicated and also placed on a separate page. ICSP connector(In Circuit Serial Programming, programming a device included in a circuit using a serial protocol). Please note that there is no slave select pin - SS on the ICSP connector. it is assumed that the Arduino will be used as the master device on the network. But if necessary, you can assign any Arduino digital pin as SS.

    The figure shows the standard correspondence of pins to SPI buses for Arduino UNO and Nano.


    3 Library for work with SPI interface

    A special library has been written for Arduino that implements the SPI protocol. It connects like this: at the beginning of the program, add #include SPI.h.

    To start working on the SPI protocol, you need to set the settings and then initialize the protocol using the procedure SPI.beginTransaction(). You can do this with a single statement: SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE0))

    This means that we initialize the SPI protocol at a frequency of 14 MHz, data transfer starts from MSB (most significant bit), in SPI_MODE0 mode.

    After initialization, select the slave device by setting the corresponding SS pin to the state LOW.

    Then we transfer the data to the slave device with the command SPI.transfer().

    After the transfer, we return the SS to the state HIGH.


    Work with the protocol is completed with the command SPI.endTransaction().

    It is desirable to minimize the transfer execution time between the SPI.beginTransaction() and SPI.endTransaction() instructions so that there is no overlap if another device tries to initialize the data transfer using different settings.

    4 Connecting a shift register to Arduino

    Consider practical use SPI interface. We will light the LEDs by driving an 8-bit shift register via the SPI bus. Connect to Arduino shift register 74HC595. To each of the 8 outputs of the register, through a limiting resistor, we will connect an LED with a nominal value of 220 Ohms. The scheme is shown in the figure.


    5 Shift register control sketch via SPI interface

    Let's write a sketch.

    #include const int pinSelect = 8; // register select pin void setup()( SPI.begin(); // initialization of the SPI interface pinMode(pinSelect, OUTPUT); // digitalWrite(pinSelect, LOW); // select slave (register) SPI.transfer(0); // clear the contents of the register digitalWrite(pinSelect, HIGH); // end of transmission Serial.begin(9600); } void loop() ( for (int i=0; i )

    First, we will connect the SPI library and initialize the SPI interface. Let's define pin 8 as the SS slave select pin. Clear the shift register by sending it the value "0". Initialize the serial port.

    To light a specific LED with shift register, you need to apply an 8-bit number to its input. For example, to light up the first LED, we supply the binary number 00000001, for the second - 00000010, for the third - 00000100, etc. These binary numbers, when translated into the decimal number system, form the following sequence: 1, 2, 4, 8, 16, 32, 64, 128 and are powers of two from 0 to 7.

    Accordingly, in the cycle loop() by the number of LEDs, we recalculate from 0 to 7. Function pow(base, exponent) raises 2 to the power of the loop counter. Microcontrollers do not work very accurately with "double" type numbers, so we use the rounding function to convert the result to an integer. round(). And we transfer the resulting number to the shift register. For clarity, the serial port monitor displays the values ​​that are obtained during this operation: unity "runs" through the discharges - the LEDs light up in a wave.

    6 "Running Wave" from LEDs

    The LEDs light up in turn, and we observe a running "wave" of lights. The LEDs are controlled using a shift register, to which we connected via the SPI interface. As a result, only 3 Arduino pins are used to control 8 LEDs. If we were to connect the LEDs directly to the Arduino digital ports, we would need to use a separate port for each LED.

    We have studied the simplest example of working Arduino with the SPI bus. Let's take a closer look at the operation of several shift registers with independent and cascade connections in a separate article.

    SPI - Serial Peripheral Interface - serial

    peripheral interface

    SPI is a serial synchronous data transfer standard between microcircuits in full duplex mode.

    This interface was originally developed by Motorola to provide simple and inexpensive interfacing of microcontrollers and peripherals, and is currently used in products from many manufacturers.

    The SPI interface, along with I2C, is one of the most widely used interfaces for connecting chips. Its name is an abbreviation for “Serial Peripheral Interface” (English, SPI bus -

    SPI bus), which reflects its purpose - a bus for connecting external devices. The SPI bus is organized on a master-slave basis. The bus master is usually a microcontroller, but it can also be a programmable logic, DSP controller, or ASIC. Bus connected to the master external devices form a slave bus. Their role is played by various kinds of microcircuits, incl. storage devices (EEPROM, Flash-memory, SRAM), real-time clock (RTC), ADC/DAC, digital potentiometers, specialized controllers, etc.

    The main component of the SPI interface is a conventional shift register, the synchronization and bitstream input/output signals of which form the interface signals. Thus, the SPI protocol is more correctly called not a data transfer protocol, but a data exchange protocol between two shift registers, each of which simultaneously performs both the function of a receiver and the function of a transmitter.

    1. Electrical connection

    IN different from the standard serial port (eng. standard serial port ), SPI is a synchronous interface in which any transmission is synchronized to a common clock signal generated by the master (processor). The receiving peripheral (slave) synchronizes the receipt of the bit sequence with the clock signal. Multiple ICs can be connected to a single serial peripheral interface of a master IC. The master selects the slave for transmission by activating the chip select signal on the slave chip. Peripherals not selected by the processor do not take part

    in SPI transmission.

    SPI uses four digital signals:

    MOSI (Eng. Master Out Slave In) - master output (alternative designation DO, SDO, DOUT), input of a slave device for serial data reception (alternative designation DI, SDI, DIN). Used to transfer data from the master to the slave.

    MISO (Eng. Master In Slave Out) - input of the master device for serial data reception (alternative designation DI, SDI, DIN), output of the slave device for serial data transmission (alternative designation DO, SDO, DOUT). Serves to transfer data from the slave to the master.

    SCLK (eng. Serial clock) - serial clock signal (alternative designation DCLOCK, CLK, SCK). Serves to transmit a clock signal for slave devices.

    CS or SS - chip selection, slave selection

    (English Chip Select, Slave Select).

    There are three types of connection to the SPI bus, each of which involves four signals. The simplest connection, in which only two microcircuits are involved, is shown in Figure 1.

    Rice. 1. The simplest connection to the SPI bus

    Here, the bus master transmits data on the MOSI line in synchronism with its own generated SCLK signal, and the slave captures the transmitted data bits on certain edges of the received clock signal. At the same time, the slave sends its data packet. The scheme presented can be simplified by omitting the MISO line if the slave IC used does not provide for, or is not required to send back data. One-way data transfer can be found in such microcircuits as DACs, digital potentiometers, programmable amplifiers and drivers. Thus, the considered option of connecting a slave IC requires 3 or 4 communication lines. In order for the slave IC to receive and transmit data, in addition to the presence of a clock signal, it is also necessary that the SS line be driven low. Otherwise, the slave IC will be inactive. When only one external IC is used, it can be tempting to exclude the SS line as well by hard-setting the select input of the slave IC low. Such a solution is highly undesirable and may lead to failures or even the impossibility of data transfer, because. the chip select input serves to reset the IC to its initial state and sometimes initiates the output of the first bit of data.

    If it is necessary to connect several microcircuits to the SPI bus, either an independent (parallel) connection (Fig. 2) or a cascade (serial) connection (Fig. 3) is used.

    Rice. 2. Independent connection to the SPI bus

    Rice. 3. Cascading to SPI bus

    Independent connection is more common, because. achieved using any SPI-compatible chips. Here, all signals, except for the choice of chips, are connected in parallel, and the bus master, by transferring one or another SS signal to a low state, sets which slave IC it will exchange data with. The main disadvantage of such a connection is the need for additional lines for addressing slave microcircuits (the total number of communication lines is 3 + n, where n is the number of slave microcircuits). Cascading is free from this shortcoming, because here from

    several microcircuits form one large shift register. To do this, the transmit data output of one IC is connected to the receive data input of the other, as shown in Figure 3. The chip select inputs are connected in parallel here, and thus the total number of communication lines is kept at 4. However, cascading is only possible if its support is specified in the documentation for the chips used. To find out, it is important to know that such a connection is called "daisy-chaining" in English.

    2. Transfer Protocol

    The SPI transfer protocol is extremely simple and, in fact, is identical to the logic of the shift register, which consists in performing a shift operation and, accordingly, bit-by-bit input and output of data on certain edges of the synchronization signal. Data set on transmit and fetch on receive are always performed on opposite clock edges. This is necessary to ensure that data is retrieved after it has been reliably established. If we take into account that the rising or falling edge can act as the first edge in the transmission cycle, then there are four possible options for the logic of the SPI interface. These options are called SPI modes and are described by two parameters:

    CPOL - the initial level of the synchronization signal (if CPOL=0, then the synchronization line before the start of the transmission cycle and after its end has a low level (i.e. the first edge is rising, and the last edge is falling), otherwise, if CPOL=1, - high (i.e. the first front is falling, and the last is rising));

    CPHA - synchronization phase; this parameter determines the sequence in which data is set and sampled (if CPHA=0, then the data will be sampled on the rising edge in the synchronization cycle, and then, on the falling edge, the data will be set

    data; if CPHA=1, then data will be set on the rising edge of the clock cycle, and fetched on the falling edge).

    The master and slave chips operating in different SPI modes are not compatible, so it is important to clarify which modes are supported by the bus master before selecting slave chips. SPI hardware modules integrated into microcontrollers in most cases support the ability to select any SPI mode and, therefore, any SPI slave microcircuits can be connected to them (only applies to an independent connection option). In addition, the SPI protocol in any of the modes is easily implemented in software.

    Tab. 1. SPI modes

    Temporary

    diagram

    synchronization

    3. Comparison with I2 C bus

    As already mentioned, for docking microcircuits, 2-wire is no less popular. serial bus I2 C. Below you can find the advantages that this or that serial bus gives.

    Benefits of the SPI bus

    Advantages of the I2C bus

    Extreme simplicity of the protocol

    transmission at the physical layer

    ensures high reliability and

    transmission speed. limiting

    SPI bus speed is measured

    The I2 C bus remains two-wire,

    tens of megahertz and, therefore, it

    regardless of the number

    ideal for streaming

    microcircuit connected to it.

    large amounts of data and widely

    used in high speed

    DAC/ADC, LED drivers

    displays and memory chips

    All SPI bus lines are

    unidirectional, which is essential

    Multi-master capability

    simplifies problem solving

    operation when connected to the bus

    level conversions and

    several leading microcircuits.

    galvanic isolation of microcircuits

    I2C protocol is more

    standardized, so

    Ease of software implementation

    I2C chip user more

    SPI protocol.

    protected from problems

    incompatibility of selected

    components.

    4. Derived and compatible protocols

    MICROWIRE.

    The MICROWIRE protocol from National Semiconductor is identical to the SPI protocol in mode 0 (CPOL = 0, CPHA = 0).

    Maxim 3-wire interface

    The difference with this interface is that instead of full-duplex transmission over two unidirectional lines, it performs half-duplex transmission over one bidirectional DQ line.

    QSPI

    A higher level protocol than SPI that allows automated data transfer without CPU involvement.

    In addition, the SPI interface is the basis for building a number of specialized interfaces, incl. JTAG debugging interface and Flash memory card interfaces, incl. SD and MMC.

    Instruction

    SPI- Serial Peripheral Interface or "Serial Peripheral Interface" is a synchronous transmission protocol for interfacing a master device (Master) with peripheral devices (Slave). The master device is often . Devices communicate over four wires, which is why SPI is sometimes referred to as a "four-wire interface". Here are the tires:
    MOSI (Master Out Slave In)- data transmission line from master to slave devices;
    MISO (Master In Slave Out)- transmission line from slave to master;
    SCLK (Serial Clock)- synchronization clock generated by the master;
    SS (Slave Select)- slave device selection line; when the line is "0", the slave device "understands" that it is now being accessed.
    There are four data transfer modes (SPI_MODE0, SPI_MODE1, SPI_MODE2, SPI_MODE3) due to the combination of clock polarity (we work on the HIGH or LOW level), Clock Polarity, CPOL, and the phase of the clock pulses (synchronization on the leading or trailing edge of the clock pulse), Clock Phase, CPHA.
    The figure shows two options for connecting devices using the SPI protocol: independent and cascaded. With an independent connection to the SPI bus, the master device accesses each slave device individually. With cascade - the devices work in turn, in a cascade.

    In the Arduino, the SPI interface buses are on specific ports. Each board has its own pin assignment. For convenience, the conclusions are duplicated and also placed on a separate ICSP connector (In Circuit Serial Programming, a device included in the circuit, using a serial protocol). Please note that there is no slave select pin - SS on the ICSP connector. it is assumed that the Arduino will be used as the master device on the network. But if necessary, you can assign any Arduino pin as SS.
    The figure shows the standard correspondence of pins to SPI buses for Arduino UNO and Nano.

    A special one has been written for Arduino that implements the SPI protocol. It connects like this: at the beginning of the program, add #include SPI.h
    To start working with the SPI protocol, you need to set the settings and then initialize the protocol using the SPI.beginTransaction() procedure. You can do this with a single statement: SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE0)).
    This means that we initialize the SPI protocol at 14 MHz, the data is transmitted starting from the MSB (most significant bit), in the "0" mode.
    After initialization, we select the slave device by transferring the corresponding SS pin to the LOW state.
    Then we transfer the data to the slave device with the SPI.transfer () command.
    After transmission, we return SS to the HIGH state.
    The work with the protocol is completed with the SPI.endTransaction() command. It is desirable to minimize the transfer execution time between the SPI.beginTransaction() and SPI.endTransaction() instructions so that there is no overlap if another device tries to initialize the data transfer using different settings.

    Consider the practical application of the SPI interface. We will light the LEDs by driving an 8-bit shift register via the SPI bus. Connect register 74HC595 to Arduino. We will connect an LED to each of the 8 outputs (through a limiting resistor). The scheme is shown in the figure.

    Let's write a sketch.
    First, we will connect the SPI library and initialize the SPI interface. Let's define pin 8 as the slave select pin. Clear the shift register by sending it the value "0". Initialize the serial port.
    To light a certain LED using a shift register, you need to apply an 8-bit number to its input. For example, to light up the first LED, we supply the binary number 00000001, for the second - 00000010, for the third - 00000100, etc. These binary numbers translated into the decimal number system form the following sequence: 1, 2, 4, 8, 16, 32, 64, 128 and are powers from 0 to 7.
    Accordingly, in the loop() loop, we recalculate from 0 to 7 by the number of LEDs. Function pow(base, exponent) raises 2 to the power of the loop counter. Microcontrollers do not work very accurately with "double" type numbers, so we use the round() function to convert the result to an integer. And we transfer the resulting number to the shift register. For clarity, the serial port monitor displays the values ​​that are obtained during this operation: the unity runs through the digits - the LEDs light up in a wave.

    Introduction

    SPI (3-wire) is a popular interface for serial data exchange between microcircuits. The SPI interface, along with I 2 C, is one of the most widely used interfaces for connecting microcircuits. It was originally invented by Motorola, and is currently used in the products of many manufacturers. Its name is an abbreviation for "Serial Peripheral Bus", which reflects its purpose - a bus for connecting external devices. The SPI bus is organized on a master-slave basis. The bus master is usually a microcontroller, but it can also be a programmable logic, DSP controller, or ASIC. The external devices connected to the master bus form the slave bus. Their role is played by various kinds of microcircuits, incl. storage devices (EEPROM, Flash-memory, SRAM), real-time clock (RTC), ADC/DAC, digital potentiometers, specialized controllers, etc.

    The main component of the SPI interface is a conventional shift register, the synchronization and bitstream input/output signals of which form the interface signals. Thus, the SPI protocol is more correctly called not a data transfer protocol, but a data exchange protocol between two shift registers, each of which simultaneously performs both the function of a receiver and the function of a transmitter. An indispensable condition for data transfer on the SPI bus is the generation of a bus clock signal. This signal has the right to generate only the master bus and the operation of the slave bus completely depends on this signal.

    Electrical connection

    There are three types of connection to the SPI bus, each of which involves four signals (see Table 1 for their main and alternative designations). The simplest connection, which involves only two chips, is shown in Figure 1. Here, the bus master transmits data on the MOSI line in synchronism with the SCLK signal generated by it, and the slave captures the transmitted data bits on certain edges of the received clock signal. At the same time, the slave sends its data packet. The scheme presented can be simplified by omitting the MISO line if the slave IC used does not provide for, or is not required to send back data. One-way data transfer can be found in such microcircuits as DACs, digital potentiometers, programmable amplifiers and drivers. Thus, the considered option of connecting a slave IC requires 3 or 4 communication lines. In order for the slave IC to receive and transmit data, in addition to the presence of a clock signal, it is also necessary that the SS line be driven low. Otherwise, the slave IC will be inactive. When only one external IC is used, it can be tempting to exclude the SS line as well by hard-setting the select input of the slave IC low. Such a solution is highly undesirable and may lead to failures or even the impossibility of data transfer, because. the chip select input serves to reset the IC to its initial state and sometimes initiates the output of the first bit of data.


    Rice. 1. The simplest connection to the SPI bus

    If it is necessary to connect several microcircuits to the SPI bus, either an independent (parallel) connection (Fig. 2) or a cascade (serial) connection (Fig. 3) is used. Independent connection is more common, because. achieved using any SPI-compatible chips. Here, all signals, except for the choice of chips, are connected in parallel, and the bus master, by transferring one or another SS signal to a low state, sets which slave IC it will exchange data with. The main disadvantage of such a connection is the need for additional lines for addressing slave microcircuits (the total number of communication lines is 3 + n, where n is the number of slave microcircuits). Cascading is free from this shortcoming, because here, one large shift register is formed from several microcircuits. To do this, the transmit data output of one IC is connected to the receive data input of the other, as shown in Figure 3. The chip select inputs are connected in parallel here, and thus the total number of communication lines is kept at 4. However, cascading is only possible if its support is specified in the documentation for the chips used. To find out, it is important to know that such a connection is called "daisy-chaining" in English.


    Rice. 2. Independent connection to the SPI bus


    Rice. 3. Cascading to SPI bus

    Transfer Protocol

    The SPI transfer protocol is extremely simple and, in fact, is identical to the logic of the shift register, which consists in performing a shift operation and, accordingly, bit-by-bit input and output of data on certain edges of the synchronization signal. Data set on transmit and fetch on receive are always performed on opposite clock edges. This is necessary to ensure that data is retrieved after it has been reliably established. If we take into account that the rising or falling edge can act as the first edge in the transmission cycle, then there are four possible options for the logic of the SPI interface. These options are called SPI modes and are described by two parameters:

    • CPOL - the initial level of the synchronization signal (if CPOL=0, then the synchronization line before the start of the transmission cycle and after its end has a low level (i.e. the first edge is rising, and the last edge is falling), otherwise, if CPOL=1, - high (i.e. the first front is falling, and the last is rising));
    • CPHA - synchronization phase; this parameter determines the sequence in which data is set and retrieved (if CPHA=0, then the data will be sampled on the rising edge in the synchronization cycle, and then, on the falling edge, the data will be set; if CPHA=1, then the setting data will be taken on the rising edge in the clock cycle and sampled on the falling edge). Information on SPI modes is summarized in Table 2.

    The master and slave chips operating in different SPI modes are not compatible, so it is important to clarify which modes are supported by the bus master before selecting slave chips. SPI hardware modules integrated into microcontrollers in most cases support the ability to select any SPI mode and, therefore, any SPI slave microcircuits can be connected to them (only applies to an independent connection option). In addition, the SPI protocol in any of the modes is easily implemented in software.

    Comparison with busbar I 2 C

    As already mentioned, the 2-wire serial bus I 2 C is no less popular for docking microcircuits. Below you can see the benefits that this or that serial bus gives.

    Benefits of the SPI bus Advantages of the I2C bus
    The extreme simplicity of the transmission protocol at the physical layer determines the high reliability and speed of transmission. SPI bus speed limit is measured in tens of megahertz and is therefore ideal for large data streaming and is widely used in high speed DAC/ADC, LED display drivers and memory chips The I 2 C bus remains two-wire, regardless of the number of chips connected to it.
    All SPI bus lines are unidirectional, which greatly simplifies the task of level conversion and galvanic isolation of microcircuits Possibility of multi-master operation when several master microcircuits are connected to the bus.
    Ease of software implementation of the SPI protocol. The I2C protocol is more standardized, therefore, the user of I2C chips is more protected from incompatibility issues of selected components.

    Derived and compatible protocols

    • MICROWIRE.

      The MICROWIRE protocol from National Semiconductor is identical to the SPI protocol in mode 0 (CPOL = 0, CPHA = 0).

    • Maxim 3-wire interface

      The difference with this interface is that instead of full-duplex transmission over two unidirectional lines, it performs half-duplex transmission over one bidirectional DQ line.

    • QSPI

      A higher level protocol than SPI that allows automated data transfer without CPU involvement.

    In addition, the SPI interface is the basis for building a number of specialized interfaces, incl. JTAG debugging interface and Flash memory card interfaces, incl. SD and MMC.

    Tab. 1. SPI bus electrical signals

    Leading tires slave bus
    Basic designation Alternative notation Description Basic designation Alternative notation Description
    MOSI DO, SDO, DOUT MOSI DI, SDI, DIN
    MISO DI, SDI, DIN Serial receive input MISO DO, SDO, DOUT Serial output
    SCLK DCLOCK, CLK, SCK Data transfer synchronization output SCLK DCLOCK, CLK, SCK Receive synchronization input
    SS CS Slave select output (chip select) SS CS Slave select input (chip select)


    Loading...
    Top