Chapter 9. Adding Peripherals Using SPI and I2C

Thirty spokes meet at a nave;Because of the hole we may use the wheel.Clay is molded into a vessel;Because of the hollow we may use the cup.Walls are built around a hearth;Because of the doors we may use the house.Thus tools come from what exists,But use from what does not.

Lao Tse, Tao Te Ching

In this chapter, we’ll look at two simple interfaces used to connect peripheral chips to microcontrollers, within a single embedded system. These interfaces allow you to connect devices such as real-time clocks, nonvolatile memories for parameter storage, sensor interfaces, and much more. The interfaces are easy to use and cheap to implement, making them ideal for small embedded applications. Some microcontrollers incorporate both types of interface, whereas others may have only one or the other. Which to use really depends on what your processor has to offer and the requirements of the particular peripheral you’re using.

Serial Peripheral Interface

The Serial Peripheral Interface (known as SPI) was developed by Motorola to provide a low-cost and simple interface between microcontrollers and peripheral chips. (SPI is sometimes also known as a four-wire interface.) It can be used to interface to memory (for data storage), analog-digital converters, digital-analog converters, real-time clock calendars, LCD drivers, sensors, audio chips, and even other processors. The range of components that support SPI is large and growing all the time.

Unlike ...

Get Designing Embedded Hardware now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.