Synchronous Microcontroller Communication Interfaces: SPI and Microwire versus I2C
In this article series, I will make the attempt to describe in the allotted space the various interface types, highlight their typical uses, summarize the key electrical and physical parameters, and point out the features and benefits of each. My goal is to provide you with some key information in a concise format that hopefully will make your task of selecting interfaces for your next application easier.
The types of interfaces available to you can be classified into two basic
categories: Synchronous interfaces and asynchronous interfaces. In this article
we'll focus on synchronous interfaces.
Microwire and SPI versus I2C
SPI is a close cousin of the older Microwire. Both interfaces are very simple and basically consist only of an 8-bit serial shift register and (for master devices) a programmable shift clock. There is no means of addressing devices. Typical applications consist of one master device (usually a microcontroller) and one or multiple slave devices (usually peripheral functions, like A/D, EEPROM, display drivers, etc.).
I2C is quite a bit more complex than SPI and Microwire, which results in a larger silicon area and therefore slightly more expensive devices. In addition Philips is collecting licensing fees for I2C implementations from competitors, adding to the cost of I2C devices.
Connecting External Peripherals
There is a minimum of 3 connections for SPI and Microwire: serial clock, serial data out and serial data in. Therefore you'll see those interfaces sometimes referred to as 3-wire interfaces. The interconnected devices need to also share the same Vcc and GND of course and in the case of multiple connected devices you need one chip select for each connected slave device (for just one slave, the slave's chip select can be enabled all the time – not recommended, but possible).
If you want to connect N devices to your microcontroller with Microwire or SPI you need to sacrifice 3+N pins to do the job. This is an area where I2C has an advantage. I2C features a 7-bit address as part of the protocol. As such I2C can address up to 128 devices on the bus without the need for dedicated chip select signals.
The Need For Speed
Microwire and SPI shine when it comes to speed. I2C was initially
specified at a maximum speed of 100kbits/sec. This was later increased to
400kbits/sec and lately some devices started to show up that boast 1Mbits/sec.
This still pales in comparison to Microwire and SPI speeds. SPI has the edge
over Microwire, due to the availability of higher speed peripheral devices.
Today's serial EEPROM for example support up to 3MBits/s for Microwire and up to
10Mbits/sec for SPI. But even the slowest Microwire and SPI peripherals still
beat the typical 100 or 400kbit/s I2C speeds.
I2C offers better support for multi-master systems. The interface has built in arbitration to detect multiple devices sending on the bus at the same time and to give priority to the one that first sends a "0". Microwire would require some software implemented handshaking via a standard I/O pin to allow for multiple master devices on the bus. SPI has a crude way to support multi-master systems via its built in "fault logic". It can detect requests of devices to become the master via the dedicated SS (slave select) pin.
One possible disadvantage of I2C should not go unmentioned: Higher noise sensitivity and along with it lower data integrity. I2C uses a read/write bit which follows the initial 7 address bits to tell a peripheral whether data should be read or written. In addition I2C is level sensitive - in contrast to Microwire and SPI, which are edge sensitive. This means that I2C samples data during the high or low phase of a bit and you can easily envision that noise could flip the read/write bit. So if you wanted to read data from your external EEPROM, but noise turned your read bit into a write bit, your memory might get corrupted. Microwire and SPI peripherals on the other hand implement read and write operations via explicit commands send over the bus, making selecting the "wrong" operation less likely.
So which synchronous interface should you give the preference?
If you have many devices to connect and in addition have multiple
microcontrollers in your system that can act as masters, then I2C is
the interface of choice. The same holds true if you need to keep the number of
interconnects, board routing and pins required for the interface to an absolute
minimum. The I2C interface is very popular in video and audio
applications, due to Philips' (microcontroller & application specific
peripheral) dominance in those applications. If you develop such applications
you might not find your desired peripheral function with any other interface.
About the Author
Volker Soffel is the General Manager of
MicroController Pros Corporation (uCPros). uCPros offers services in:
Electronic system design with a focus on embedded systems; marketing and
management consulting; employee training; technical writing and translations.
uCPros also publishes a free monthly
Embedded News Digest email
newsletter, covering the latest events in the microcontroller industry.
Email us with
questions or comments about this web site.