Interfacing with a Secure Digital (SD) card

From Mech
Jump to navigationJump to search

Original Assignment

Establish SPI communication between your PIC and a Secure Digital (SD) card for data logging. Demonstrate the ability to store data on the card and to read it back later.

Overview

Secure Digital Cards, or SD cards, are used to hold information in many common electronic devices from digital cameras to mobile phones and come in sizes as small as 16-32 MB and as large as 8 GB. In this lab, we will establish communication between a Microchip PIC 18F4520 and a 2GB SD card manufactured by Apacer.

SD cards can operate three different communication modes: One-bit SD mode, Four-bit SD mode, and SPI mode. SPI is a more basic protocol and it is widely supported by many microcontrollers, including the PIC 18F4520. We'll be using SPI mode in this lab.

Circuit

An SD card has 9 pins. Only 7 of these pins are used to communicate with an SD card in SPI mode. SD cards require between 2 and 3.6 VDC. In this lab, we use a bench top power supply to provide 3.3 VDC to both the PIC and to the SD card. 50k pull-up resistors are essential, even for the pins that are not being used for SPI communications. Note that a pull-up resistor should not be used on the clock line.

Circuit Diagram