Reading to and writing from an SD card on a FRDM-MK64 board using mbed

File uploaded by Ben Trevett Employee on Jul 24, 2014Last modified by Ben Trevett Employee on Sep 11, 2015
Version 3Show Document
  • View in full screen mode

Reading and Writing to SD Card




A small project made with mbed ( on the FRDM-MK64 using the SD card capabilities.

The program will open a file called test.txt in the root of the SD card, and will create one if it does not exist.

It will then write "one two three four five" in the .txt file.

It will then read the text and output the result.
You will need a terminal application (I recommend Termite) in order to see the outputs.


The current program overwrites anything that was previous on the SD card.

To prevent this, change the "w" to "a" during the writing process.

This changes the instruction from a 'write' to an 'append'.


This should be compatible with all boards that have an SD card connected.

However the appropriate pins from SDFileSystem will have to be changed to suit the board.

Check your board's schematic for the appropriate pins.