SDFileSystem for mbed platfrom

This post shows how to use SDfile System on W5500 Ethernet Shield for mbed platfrom.

SDFile System

A library to allow SD Cards to be accessed as a filesystem, using a SPI interface

SDFileSystem @developer.mbed.org/handbook

This library supports:
– Fat12/ FAT16 / FAT32
– SD / SDHC cards up to 32Gb

HW – W5500 Ethernet Shield with MicroSD Slot

W5500 Ethernet Shield

W5500 Ethernet Shield

  • ARM mbed compatible operation
  • Arduino Pin-compatible
  • Ethernet (W5500 Hardwired TCP/IP chip)
  • MicroSD Slot
  • Ethernet port
  • I2C I/F
  • UART I/F

W5500 Ethernet Shiel Pin Map

W5500 Ethernet Shiel Pin Map

  • SPI Bus support Arduino and mbed platfrom
    MOSI MISO SCK
    D11 D12 D13
    MOSI(ICSP-4) MISO(ICSP-1) SCLK(ICSP-3)
  • SPI_CS and SD_CS pins are allowed to select as below,

    • SPI_CS : D8 / D9 / D10
    • SD_CS : D4 / D5 / D6

SW1 – SDFile System for LPC824 Xpresso (mbed platform)

/**  import SDFiles System Library **/
#include "mbed.h"
#include "SDFileSystem.h"

/*for LPC824 Xpresso */
SDFileSystem sd(D11, D12, D13, D6, "SD"); // the pinout on the mbed Cool Components workshop board
int main() {
    printf("Hello World!n");   
    mkdir("/SD/mydir", 0777);
    FILE *fp = fopen("/SD/mydir/sdtest.txt", "w");
    if(fp == NULL) {
        error("Could not open file for writen");
    }
    fprintf(fp, "Hello fun SD Card World!");
    fclose(fp); 
    printf("Goodbye World!n");
}

SW2 – SDFile System for FRDM-KL25Z (mbed platform)

/**  import SDFiles System Library **/
#include "mbed.h"
#include "SDFileSystem.h"

/*for FRDM-KL25Z */
SDFileSystem sd(D11, D12, D13, D4, "SD"); // the pinout on the mbed Cool Components workshop board
int main() {
    printf("Hello World!n");   
    mkdir("/SD/mydir", 0777);
    FILE *fp = fopen("/SD/mydir/sdtest.txt", "w");
    if(fp == NULL) {
        error("Could not open file for writen");
    }
    fprintf(fp, "Hello fun SD Card World!");
    fclose(fp); 
    printf("Goodbye World!n");
}

Demo.

Notice: SD card name shoud be same variable in sd(mosi, miso, clk, “SDname”).
* Serial terminal
minicom
* Check SD card by using card reader
read SD card
* Confirm stdtest.txt
read SD card

Advertisements

One thought on “SDFileSystem for mbed platfrom

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s