SDFileSystem for mbed platfrom

This post shows how to use SDfile System on W5500 Ethernet Shield for mbed platfrom.
ORIGINAL POST
By embeddist
components
Hardware Components
W5500 Ethernet Shield with MicroSD Slot
X 1
LPC824 Xpresso
X 1
details

ucc_april_2.jpg

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
    MOSIMISOSCK
    D11D12D13
    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)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**  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)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**  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

ucc_april_2.jpg

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
    MOSIMISOSCK
    D11D12D13
    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)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**  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)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**  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

COMMENTS

Please Login to comment
  Subscribe  
Notify of
POSTED BY
TAGS
Reusable S/W