SD card support for the CC2650 LaunchPad
LaunchPad SD

Final Project in Advance Computer Systems (Fall 2016)

Lead Instructor: Professor Sivan Toledo.

By: Daniel Kuperman Azoulay & Sagi Aharoni

Learn More


LaunchPad SD, a project built for Texas Instrument's CC2650 Launchpad development kit, provides an easy to use API for reading/writing to SD cards using SPI. More specifically, our project is a port of the FatFS open-source FAT32 file system to TI-RTOS enviroment. This is our final project in prof. Sivan Toledo's Advance Computer Systems course, which deals with embedded design and development.

Our project consists of 3 "layers" of code:

High Level API Code

Consists of user oriented code for reading/writing to the card. The API resembles Unix's file handling system calls (open, read, write, mkdir, unlink etc.) and is very easy to use.

SD Commands Implementation

SD cards supports various commands needed for intializing, reading and writing operations. This layer consists entirely of our implementation of these commands, conforming to the SD SPI protocol.

Low Level SPI Communication Code

The bottom layer of the project, consists of low level SPI communication implementation using existing SPI drivers.

Technical Details

Hardware Components

- CC2650 Launchpad
- MH-SD Card Module (SD Card Breakout Board)
- Wiring

Design Chart

SD Card Initialization Process

SD cards require to undergo an initialization process before accepting read/write commands, as seen in the below simplified flow chart.


Below is a set of useful functions from the FatFS library supported by our project. For the full list, examples of use and further documentation, visit the FatFS website.

File Access

-f_open - Open/Create a file
-f_close - Close an open file
-f_read - Read data
-f_write - Write data
-f_lseek - Move read/write pointer, Expand size
-f_gets - Read a string
-f_puts - Write a string
-f_printf - Write a formatted string

Directory Access

-f_opendir - Open a directory
-f_closedir - Close an open directory
-f_readdir - Read an directory item

File/Directory Management

-f_stat - Check existance of a file or sub-directory
-f_unlink - Remove a file or sub-directory
-f_chmod - Change attribute of a file or sub-directory
-f_mkdir - Create a sub-directory


Prior to our project completion we faced many issues. Below are some of the problems we had, and how we have managed to solve them:

"Debugging" SPI communication

Communicating with the chip wasn't an easy task: TI provides a function that transfers data over SPI, but doesn't provide any example how to use it. It took many tries to even get any meaningful feedback from the SD card that could imply it has received our messages. This is where the oscilloscope was very useful, because it enabled us to distinguish between two possible scenarios: the first is that the SD card wasn't receiving our messages and the latter is that we are unable to read the response from the SD card properly.

Working with SD card penalty

In order to begin working with the SD card, one should note it expects certain commands to be sent in a specific sequence (as shown above) in order to initialize the SD card to be able to access the data inside and allow transfering data in maximum speed. Each of the SD commands has a specific structure and arguments. Once an invalid argument is sent (by mistake), the SD card protects itself by locking itself and expecting a new initialization sequence. To overcome this issue, after a mistake was made - we had to reinitialize the SD card by sending another command or connecting the SD card to a computer, which performs the initialization sequence behind the scenes.

Communicating with the SD card

There are many complex commands that could be sent to the SD card in order to properly communicate with it. Many commands have non-trivial arguments that should be sent. The "SD Cards Assocication" provides a guide to all of the possible commands and how to invoke them properly. The guide wasn't easy to understand by us, and sometimes we had followed it but received different responses from the SD card. We had to search the web for similar responses until we found out what we have done wrong.

About Us

We are a team of 2 third-year Computer Science & Electrical Engineering students:

Daniel Kuperman Azoulay

Sagi Aharoni