I was going shoe-hunting the other day and realized exactly why I don’t buy shoes all that often: all of the parameters. I was looking for sneakers specifically so there were metrics for comfort, bounciness, durability, wet-resistance, weight, toe-size, arch-support, and more. Sometimes it feels like you need to have a graduate degree just to find the right shoe for your foot. That’s what I call an overburden of information.
You will deal with a similarly burdensome decision in electronics design when choosing between the Serial Peripheral Interface (SPI) and Inter-Integrated Circuits (I2C) protocols for memory chips. Your decision becomes even tougher when both choices don’t differ much in terms of cost. Keeping track of your memory chip parameter needs comes with the knowledge of what the functions will accomplish for your product.
SPI and I2C Fundamentals
The SPI is a communication protocol with a full duplex configuration. It uses four signals, Chip Select (CS), Clock (SCK), Master Out / Slave In (MOSI), and Master In / Slave Out (MISO), for communications between a master and a slave. A single master to slave connection requires one CS signal. This means that the number of CS signals increases if more than a single slave is connected to the same bus.
There is no official limit on the speed of an SPI bus. It is common for microcontrollers to drive the SPI bus at speeds up to 10Mhz. There are four modes of SPI where the data latches on the different edges and polarity of the clocking signal. There is, however, no standard mechanism that enables a master to confirm that the data has been successfully received and stored by the slave.
The I2C bus, on the other hand, requires only two wires, serial data (SDA), and serial clock (SCLK). It operates at a much lower speed of 100 kHz, although there are higher possible speeds that may not be supported by most microcontrollers. Slave devices connected to the I2C bus are identified by chip address, defined by the hardware. Signal pins of the microcontroller are their lowest with I2C.
A well-defined standard for I2C covers not only the speed of the protocol but also the commands, initialization, data transfer, and acknowledgment between master and slave devices. This ensures that all devices that support I2C observe a single standard for ease of implementation.
Important Considerations When Choosing Between SPI and I2C for Memory Chips
Both SPI and I2C are popular protocols with serial memory chips like Static Random Access Memory (SRAM), Flash, or Electrically Erasable Programmable Read-Only Memory (EEPROM). Determining the protocol that best suits your design requires more than comparing the cost alone. Here are some important considerations that may simplify your decision-making process:
When you’re transferring data in bulk or have a tight window to verify user input against the data stored in a memory chip, every single microsecond counts. If speed is your primary concern, choose SPI to experience a common data transfer rate of 10 MHz, much faster than I2C’s full speed of 400Khz.
If speed matters, choose SPI.
2. Limited Pins
Not all hardware designers have the joy of using high-end microcontrollers with over 100 pins. Some struggle to connect memory chips with 28-pin microcontrollers. In these situations, I2C is ideal as it only requires a couple of tracks for communication.
3. PCB Size
If you’re not bound by any PCB size constraint, then either SPI or I2C will be great for you. But if you’re trying to squeeze your PCB into a tiny enclosure, fewer tracks means a smaller PCB for which I2C is the wiser choice.
4. Glitches And Error Recovery
Designers are not perfect and neither is the I2C protocol. The I2C bus is sensitive to glitches and lockups as both the transmission and reception occur on the same physical tracks. When a master fails to release the bus in time, the slave may enter a lock-up state as it has sent a reply that the master failed to receive. Handling error recovery may be tricky, as some cases may necessitate a power reset on the lock-up devices.
If you’re designing battery operated or solar powered devices, power consumption must be minimized. I2C devices generally consume more power than SPI and if power usage is a concern, you should choose SPI for your design.
Choose I2C if you need your PCB to be small and sweet. Editorial credit: Robson90 / Shutterstock.com
Make the Best Decision for Your Design
Regardless of your ultimate choice, both SPI vs I2C protocols require signals to be routed in parallel and involve similar length to prevent any signal glitches. Your decision impacts not only the functionality of your design but also the turnaround time and overall efficiency.
By using PCB design software which can give you the functionality and tools you need to move effortlessly from schematic to layout to output, you will be able to make these design choices easily. Take advantage of multiple signal routing tools and unlimited design content to make the process easier with Altium’s CircuitStudio.
Still wondering which protocol best suits your design? Ask an expert at Altium.
Check out Altium Designer in action...
Real-time BOM Management