Accessing Flash Memory Cards

22 Mar

Accessing Flash Memory Cards
For many embedded systems, a good choice for storage is a a MultiMediaCard accessed via SPI. This chapter shows what’s involved in implementing SPI communications with MultiMediaCards. SD-Card hosts can use the same interface and firmware.

The Interface
The Serial Peripheral Interface (SPI) originated at Motorola (now Freescale Semiconductor). Many microcontrollers from Motorola/Freescale and others have hardware support for SPI. In systems without hardware support, the communications can be controlled entirely in firmware.

Every SPI communication is between a host, or master, and a MultiMediaCard or other slave device. The host controls the interface’s clock and chip-select lines.

Signals and Power
SPI has no official specification document other than the data sheets for the components that support the interface. As a result, different implementations use different names for the signals (Table 4-1). Note that the MultiMediaCard signal names are from the perspective of the MultiMediaCard card: DataIn is an input on the card, while DataOut is an output on the card.

Data and Clock Lines
Table 4-2 shows the pin functions for a MultiMediaCard in SPI mode.

SCLK (also called SCK) is the card’s clock input. The clock provides transitions that determine when to write and read data on the data lines. The SPI host generates the clock pulses.

DataIn (also called MOSI, or Master Out Slave In, or SDI) is the card’s data input. The host uses the DataIn line to send commands and to send data to the storage media.

DataOut (also called MISO, or Master In, Slave Out, or SDO) is the card’s data output. The card uses the DataOut line to send responses to commands, other status information, and data requested from the storage media.

CS (also called /SS, or Slave Select) is the device’s chip-select input. The host must control a unique chip-select output for each card on the bus. The host selects a card by bringing the card’s CS input low.

Power
Each card also has a power-supply pin (VDD) and two ground pins (VSS and VSS2). A high-voltage MultiMediaCard requires a supply voltage of
3.3V. A low-voltage MultiMediaCard can be powered at either 3.3V or 1.8V.

Example Circuit
An SPI host can be a microcontroller with hardware SPI support or any generic microcontroller or other intelligent hardware with available port pins and the ability to implement communications entirely in firmware.

Table 4-1: Because there is no signal specification document for SPI, the signal names used by different sources vary.

Microchip’s PIC18F4550 microcontroller has an SPI port and can serve as a MultiMediaCard host. Chapter 2 discussed using this chip for USB mass-storage communications.

Figure 4-1 shows connections between a PIC18F4550 and a MultiMediaCard/ SD-Card connector. The circuit is similar to the circuits on Microchip’s PICtail® board for SD Cards and MultiMediaCard cards. The PICtail board attaches to a header on Microchip’s PICDEM® Full Speed USB demonstration board. A spring-loaded latch holds the card in place. The microcontroller is powered at +5V to enable clocking the chip faster than 16 Mhz (up to 48 Mhz). The MultiMediaCard operates at +3.3V. Pull-up resistors and buffers perform the voltage translations.

On the MultiMediaCard connector, pins 1–7 connect to the MultiMediaCard’s pins. The CD pin connects to a card-detect switch, and the WP pin connects to a write-protect switch.

Port outputs on the microcontroller drive 5V-tolerant inputs of buffers powered at +3.3V. The buffer’s outputs in turn drive the CD, DataIn, and SCLK inputs on the MultiMediaCard. Pull-up resistors bring the logic-high buffer outputs close to +3.3V.

The Multimedia card’s DataOut output drives an input of a buffer powered at +5V. The buffer has TTL-compatible input voltages. When DataOut is high, a pull-up resistor brings the voltage near 3.3V, which is well above the buffer’s 2V minimum logic-high input requirement. The buffer’s 5V-logic output drives input port pins on the microcontroller. In a similar way, the MultiMediaCard connector’s CD and WP pins drive buffer inputs, and the corresponding buffer outputs connect to input port pins on the microcontroller.

Table 4-2: Pin functions for a MultiMediaCard in SPI mode.

Figure 4-1: The pins on the MultiMediaCard/SD-Card connector connect to port pins on the PIC18F4550.

If the PIC18F4550 or another MultiMediaCard host is powered at 3.3V, the level-translation circuits are unneeded and the host can interface directly to the MultiMediaCard, but the maximum clock frequency (at Fosc) is 16 Mhz.

Random Posts

No comments yet

Leave a Reply

You must be logged in to post a comment.