We are independent & ad-supported. We may earn a commission for purchases made through our links.
Advertiser Disclosure
Our website is an independent, advertising-supported platform. We provide our content free of charge to our readers, and to keep it that way, we rely on revenue generated through advertisements and affiliate partnerships. This means that when you click on certain links on our site and make a purchase, we may earn a commission. Learn more.
How We Make Money
We sustain our operations through affiliate commissions and advertising. If you click on an affiliate link and make a purchase, we may receive a commission from the merchant at no additional cost to you. We also display advertisements on our website, which help generate revenue to support our work and keep our content free for readers. Our editorial team operates independently of our advertising and affiliate partnerships to ensure that our content remains unbiased and focused on providing you with the best information and recommendations based on thorough research and honest evaluations. To remain transparent, we’ve provided a list of our current affiliate partners here.
Hardware

Our Promise to you

Founded in 2002, our company has been a trusted resource for readers seeking informative and engaging content. Our dedication to quality remains unwavering—and will never change. We follow a strict editorial policy, ensuring that our content is authored by highly qualified professionals and edited by subject matter experts. This guarantees that everything we publish is objective, accurate, and trustworthy.

Over the years, we've refined our approach to cover a wide range of topics, providing readers with reliable and practical advice to enhance their knowledge and skills. That's why millions of readers turn to us each year. Join us in celebrating the joy of learning, guided by standards you can trust.

What is the Serial Peripheral Interface?

By Marco Sumayao
Updated: May 16, 2024
Views: 9,919
Share

A serial peripheral interface (SPI) is a low-cost, four-wire, full-duplex synchronous serial communication data stream interface that operates in a master-slave relationship. Data transfer in serial devices occurs one bit at a time, making SPI a low-speed interface. It is commonly used as a link between integrated circuits with on-board slow peripheral devices that are accessed intermittently. It competes with parallel data transmission devices, but as SPI increases in efficiency, the former's advantage is reduced. SPI is sometimes referred to as "microwire," although this is considered as a subset protocol of SPI.

Data transfers by a serial peripheral interface occur via full-duplexed protocol. Data is transferred and received in both directions at the same time. Applications using SPI gain much efficiency in this mode; one such application is between a coder-decoder (codec) and a Digital Signal Processor (DSP). Other applications include temperature and pressure sensors, as well as flash memory.

Whenever two serial peripheral interface devices communicate, one device is referred to as the "master," while the other device is the "slave." The master device initiates all communications by transmitting signals to the slave device. A serial peripheral interface bus can connect multiple slave devices to a single master.

Serial peripheral interface devices use three registers—control register (SPCR), status register (SPSR), and data register (SPDR)—in sending data, along with four different signals. The first signal is called serial clock (SCLK), which only the master device generates. This is followed by master-out slave-in (MOSI), master-in slave-out (MISO), and slave select (SSn), where "n" is the number of slave devices to which the master device is connected.

In a typical single-slave configuration, an engineer looking to use a serial peripheral interface would connect SCLK to a slave device's input. MOSI then carries data from the master device to the slave device while MISO transfers data from the slave to the master. To determine which device is master and which is slave, the former connects Master SSn to Slave SSn and generates a general-purpose discrete input/output signal to the latter.

To connect multiple slaves to one master in a serial peripheral interface, separate SSn signals are connected from the master device to separate slaves. For example, SS1 is connected to Slave 1, SS2 is connected to Slave 2, and so on. Similar to single-slave configuration, SCLK is connected from the master device to the multiple slaves. MOSI from master to slaves are connected, as well as MISO from slaves to master.

Share
EasyTechJunkie is dedicated to providing accurate and trustworthy information. We carefully select reputable sources and employ a rigorous fact-checking process to maintain the highest standards. To learn more about our commitment to accuracy, read our editorial process.
Discussion Comments
By anon319444 — On Feb 13, 2013

How do I connect if both systems are masters in the spi interface, e.g., Raspberry pi?

Share
https://www.easytechjunkie.com/what-is-the-serial-peripheral-interface.htm
Copy this link
EasyTechJunkie, in your inbox

Our latest articles, guides, and more, delivered daily.

EasyTechJunkie, in your inbox

Our latest articles, guides, and more, delivered daily.