Implementing SPI on an OMAP-based board designDmitry Pervushin describes how to add to the functionality of an OMAP-based PandaBoard by connecting a real time clock chip to the design via a Serial Peripheral Interface (SPI) created using the board’s expansion connector.
Once the OMAP-based PandaBoard became available to developers as the first open mobile development platform included by Android Open Source Platform (AOSP), the enthusiastic open source community started building exciting projects on the platform, and asking questions about extending the platform’s capabilities beyond traditional means.
While experience levels of developers working with the PandaBoard vary – from seekers of programming advice to advanced designers choosing an interface to connect to – their mission is always the same: create a compelling open-source product or application, and share knowledge with the PandaBoard community.
In that vein, this how-to article outlines the Serial Programming Interface available through the PandaBoard’s expansion connector, and as an illustration explains how to use it to connect to a real-time clock (RTC) chip.
What is SPI?
SPI stands for “Serial Programming Interface,” a simple standard that originally came from Motorola. Sometimes it is called “4-wire” interface, contrasting with 1-wire, 2-wire and 3-wire serial buses, because the interface defines four wires: MOSI (master-out-slave-in), MISO (master-in-slave-out), SCLK(serial clock from the master) and chipselect signal (CS#). Using multiple chipselects allows several devices to be connected to the same master. (Editor's Note: To learn more about SPI, go to: "The future of the Serial Peripheral Interface.")
Why SPI ? There are multiple interfaces available to connect a device to the PandaBoard: SPI, I2C, USB and others. However, using SPI to connect the peripheral device (Figure 1, below) is probably the best option because it is less expensive, easy to connect and debug, and demonstrates relatively good performance.
Figure 1. Setting up the PandaBoard SPI connection
What kind of devices can be connected to SPI?
Almost any type of device can be connected to the SPI bus, from simple analog-digital converters to ethernet adapters. Even SD cards have an “SPI mode,” which allows a developer to connect them to the SPI bus.
The SPI subsystem in Linux is well supported and offers drivers for a wide range of SPI devices. There are drivers for MTDs (SPI flash memory), SD controllers and ethernet adapters. The SPI subsystem in the Linux kernel also provides the generic “spidev” driver that exposes an API to the userspace and allows control of the peripheral outside the kernel.
How to connect an SPI device to the PandaBoard
The PandaBoard provides an expansion connector where one can find pins that are multi-channel serial port interface (MCSPI)-related. These pins are:
Pin 4 MCSPI_CS3
Pin 10 MCSPI_CS1
Pin 12 MCSPI_SIMO
Pin 14 MCSPI_CS2
Pin 16 MCSPI_CS0
Pin 18 MCSPI_SOMI
Pin 20 MCSPI_CLK
Figure 2 below shows the CS0/CS1/CS2/CS3 lines, which allow up to four devices to be connected to this master. A device will most likely be connected to MCSPI_SIMO, MCSPI_SOMI, MCSPI_CLK and MCSPI_CS0.
Figure 2: PandaBoard CS0/CS1/CS2/CS3 lines
Also of importance, the PandaBoard has 1.8V on control pins, but the sample DS3234 chip above wants 5V. Fortunately, there are “level shifters” such as the PCA9306, which allows a bidirectional voltage-level translator. Having applied 1.8V and 5V as the VREF1 and VREF2 pins of the PCA9306, and driving the ENABLE pin to high, the chip translates levels between pins SDA1/SCL1 and SDA2/SCL2.
Currently no items