SPI and I2C are probably the most commonly used digital protocols to connect integrated circuits in a diverse array of products. SPI and I2C are both easy-to-use, hard-to-break serial digital protocols that are quite easy to route from a signal integrity perspective. Unlike impedance-controlled high-speed differential serial protocols, these two protocols do not have an impedance specification and will often be considered electrically short. This means that, on the PCB, the design requirements are relatively simple and there is still some freedom within the standard to tune the performance as you would like.
One of the common implementations of SPI and I2C in a PCB layout is as a protocol for reading and writing to an external Flash memory. Flash chips are a very common component in embedded systems and can offer high capacities of non-volatile memory up to Gb values. When choosing a memory chip, you'll want to match the application requirements and functionality with the bus speed you need for read and write operations in your memory chip. There is also the matter of the type of Flash memory you'll need to access (NOR vs. NAND).
The Serial Peripheral Interface (SPI) and Inter-Integrated Circuit (I2C) protocols are both simple serial digital protocols that run at low to moderate speeds. These two interfaces have some common characteristics:
Clearly, these interfaces are very similar. They do have some important differences as summarized in the table below.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Directionality | - Half duplex | - Full duplex |
Signal driving | - Open-drain | - Push-pull (with CMOS buffer) |
The SPI standard offers higher data rates and can run with much faster edge rates compared to I2C. Due to the use of pullups on I2C, the typically high bus capacitance, and the fact that the driving method is open-drain, I2C buses can have rise times reaching 100's of nanoseconds. SPI buses can have rise times as low as 1 ns for advanced components driving low load capacitances, which means they may exhibit transient ringing during switching. SPI lines are also much more likely to produce crosstalk because their switching speed is so fast. To learn more about these two protocols and signal integrity in SPI buses, read the following resources.
In this section I don't want to get into the particulars of NAND vs. NOR Flash memories, instead I want to focus on how each is accessed with a serial protocol. Both types of Flash chips can be accessed with an SPI or I2C bus if you can procure the right memory component:
If you look on Octopart and use the filter features, you'll be able to locate some high-capacity memories that use either interface.
If you need to convert between an I2C and SPI interface, you can use an interface bridge. These components convert the data format between these interfaces, thus a component that might only have an SPI bus can then access peripheral components that only have an I2C bus. This includes memory chips, although if the controller is only using I2C and the memory is using SPI then the speed might be limited and the receiving component might not work due to long rise times.
To overcome this limitation with I2C, it's best to use a controller with SPI, and then use the interface bridge to access a peripheral that only has I2C. Note that the SPI side will have to be clocked lower to ensure it can be used at I2C speeds. This would be done in the following topology:
Another common requirement in open-drain and push-pull serial protocols (where the signal level is set by the core voltage) is level shifting. The simplest way to build a PCB is with a single power source that is regulated down to the desired core voltage, such as with an LDO. In reality, you might have some peripherals that run at a higher voltage (say, 3.3 V) while the main controller runs at lower voltage with multiple rails (2.5 V, 1.8 V, etc.). If your MCU runs at 3V3 but your memory runs at 1V8 (this is a common situation), then you will need to route your SPI or I2C signals through a level shifter. Note that some interface bridges will include a level shifter that connects to two power rails; the topology is shown below.
Once you've located components for your design, how do you decide between an SPI vs. I2C interface? Here are some points that will drive your decision:
Speed: 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 repeated read and write capability is needed in real time with the rest of your system, then use SPI. If the controller only needs to occasionally read or write from memory, then use I2C.
Controller: If you're using a very small MCU or peripheral and you have very few pins to spare, then you should go with I2C. In fact, you probably won't have a choice with some microcontrollers. For example, the classic ATTiny MCUs only have I2C, so if they need data from an external memory then you will have to find a memory chip that supports I2C.
Power: If you’re designing a battery-operated device that needs to repeatedly access data, you might opt for SPI as the interface will use less average power than an I2C interface.
SPI and I2C routing are much easier when you use the complete set of PCB design and routing features in Altium Designer®. When you’ve finished your design, and you want to release files to your manufacturer, the Altium 365™ platform makes it easy to collaborate and share your projects.
We have only scratched the surface of what’s possible with Altium Designer on Altium 365. Start your free trial of Altium Designer + Altium 365 today.