Interfacing with a Secure Digital (SD) card using pic-microcontroller




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 4 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.

Interfacing with a Secure Digital (SD) card

Hardware

Card Interface

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.

SD Card Holder

SD card holders are typically surface-mount components that are designed to be placed on printed circuit boards by machines. As such, they can be very difficult to handle and connect. At first, we were given an HR8464CT-ND SD card holder. Attempts to solder solid-core to the pins of this device caused the pins to fall out. Instead, we used an HR845CT-ND which had pins that were more resistant to axial force and thus easier to solder.

For this lab, we cut a strip of square-pinned header to the proper length and simply soldered the pins of the holder to it. See the photograph below for more detail.

Driver

Note that this lab was completed by making slight modifications to an example application included in the CCS v4.081 library. The low level driver code, included in the Drivers directory of the CCS installation, must be copied verbatim into the same directory as the application code.

Interfacing with a Secure Digital (SD) card

Application

The original, unmodified application code was included in the newer version of CCS mentioned above. Note that as of Winter Quarter 2009, these drivers are not available in the Mechatronics lab but are available on the installation media provided in our lab kits. Modifications were made to the code to change the assignment of the SPI pins, tailor the preprocessor directives to use our PIC, properly configure RS232 and set the main clock frequency.

 

For more detail: Interfacing with a Secure Digital (SD) card




Current Project / Post can also be found using:

  • interfacing of sd card with 8051 using spi
  • How to use sd card with pic microcontroller
  • interfacing pic to sd card
  • pic16F sdcard

Leave a Comment

*
= 5 + 9

Scroll to top