SPI Serial to Parallel Interface - Hardware Information

The Coat of Arms of John A. Duncan, proprietor of Huntly Computer Services

Home About Us Computer Systems Peripherals PC Repairs PC Upgrades Second Hand Forum Website Design
Web Marketing eCommerce Download Centre Software Computer Parts Contact & Map Useful Links Information Centre HCS News
You are here: SPI Serial to Parallel Interface  

"The beauty with the SPI Bus is that it is Synchronous"

Search HCS Network

Download Centre

Visit Huntly Computers Software and Service Download Centre


Broadband and ISP Providers Information

SPI firmware communications protocol

SPI Bus: Theory and Implementation

By O G Popa

SPI stands for “Serial to Parallel Interface”, and it is a hardware and firmware communications protocol developed by Motorola and adopted by everybody. This Bus is used only on the PCB. I am certain that some of you will ask: “Why is SPI used only on the PCB? What prevents us from using it outside the PCB area?” The SPI was specially designed to exchange data between various IC chips, at very high speeds; say, at 180 MHz or even more. Due to this high speed aspect, the Bus lines cannot be too long, because the reactance increases too much and the Bus becomes unusable.

However, if you want, you could use the SPI Bus outside the PCB at low speeds, only that this is not practical: the SPI Bus requires 3 or 4 lines, which are a bit too many, when compared to 1 or 2 lines needed to communicate, efficiently, with field devices outside the PCB.

Anyway, on the PCB the SPI Bus is very good, because we can practically attach to the Bus as many IC chips (or devices) as we want. Please excuse me for not providing a picture of the SPI Bus, but rest assured that you do not need one: the SPI Bus is so simple that you will understand everything in words.

The next question is: “What is this SPI Bus good for?” Besides from exchanging data between various IC chips, the SPI Bus is a method of multiplying microcontroller’s pins. In other words, if you have a tiny 8 pins microcontroller, you could control with that little monster few hundreds of digital Inputs and Outputs. This is impressive, and I am certain that many doubt my words; let’s explain this.

The SPI Bus contains three lines, and they can be on any I/O controller pins; these lines are: Clock, Data-In, and Data-Out. In addition, each IC connected to the SPI Bus needs an individual Enable line. Things work like this: suppose that we have four devices, A, B, C, and D, all wired to the SPI Bus, and the Bus itself is wired to seven controller pins--this is 3 Bus lines plus the 4 Enable ones. When we want to send a message to device C, we enable its Enable line first, than we send the message serially, one bit at a time. In the same time devices A, B, and D do exactly nothing, because they are not enabled.

The beauty with the SPI Bus is that it is Synchronous, meaning that when the controller sends the message to one IC it is also able to receive data from that IC, in the same time. This particular aspect of the SPI protocol is very well suited for microcontroller-to-microcontroller communications.

Now, we have seen that a small 8 pins microcontroller can control 4 devices (ICs) using 7 pins. Taking into account that one device of type A, B, C, and D could have eight or sixteen I/O ports this is still far from the hundreds Inputs and Outputs I promised to you. The second beautiful thing about SPI is, one device IC can be serialized with many more. For example, we could have B1, B2, B3, B4, B5, and so on. All of them are serialized together, and they require only 4 microcontroller pins to make them work: the Enable line is common to all of them. Now it is clear, I hope, that, indeed, we can have hundreds of I/O lines on a small 8 pins controller.

Further from this general presentation of the SPI Bus, you should be aware that almost all ICs implement the SIP protocol in a particular way. For detailed and practical applications I suggest that you visit my home site at Corollary Theorems. There you are going to discover a good tutorial book about working with hardware, firmware, and software design, in general, and about few practical implementations of the SPI Bus, in particular.

Many microcontrollers have built-in SPI Bus hardware modules, but I was never interested too much about using them. What I do, I always design--on the PCB and for one microcontroller--one, two or more custom SPI Busses, because my custom implementations are far more flexible. Besides, practical implementation of a custom SPI Bus it is really simple--trust me with this one!

About The Author

O G POPA is Professional Engineer in BC, Canada. His home site is Corollary Theorems at http://www.corollarytheorems.com

Back to the Technology Resource Information Centre

email Huntly Computer Services


© Huntly Computer Services 1999 - 2009

Last Update: 14-Mar-2009

Site Map Disclaimer  |

You are here: SPI Serial to Parallel Interface