I tried SD card Read Write test. Result is success.

Dependencies:   SDFileSystem mbed

/media/uploads/ImageWriter/img_4903.jpg I tried SD card read/write test.

I use Nucleo-F411RE and Aitendo's 2.2inch TFT display with SD card interface.

http://www.aitendo.com/product/7277

This test is not use TFT display. Only use SD card interface.

/media/uploads/ImageWriter/img_4862.jpg

/media/uploads/ImageWriter/img_4865.jpg

Micro SD adaptor type.

/media/uploads/ImageWriter/img_4903.jpg

/media/uploads/ImageWriter/img_4904.jpg

main.cpp

Committer:
ImageWriter
Date:
2015-04-17
Revision:
0:96613601cfb9

File content as of revision 0:96613601cfb9:

#include "mbed.h"
#include "SDFileSystem.h"
 
 
//Create an SDFileSystem object
//SDFileSystem sd(PA_7, PA_6, PA_5, PA_15, "sd");// MOSI, MISO, SCK, CS
SDFileSystem sd(D11, D12, D13, D10, "sd");// MOSI, MISO, SCK, CS
Serial pc(USBTX, USBRX);
 
int main() {
//    pc.baud(19200);
    pc.baud(9600);
    for(int i=5; i>0; i--) 
    {
        pc.printf("Wait %i seconds..\r\n",i);
        wait(1);
    }
    pc.printf("Initializing\r\n");
    
    //Mount the filesystem
 
//    sd.mount();
    
    //Perform a write test
    pc.printf("\nWriting to SD card...");
    FILE *fp = fopen("/sd/sdtest.txt", "a+");
    
    wait(2);
    if (fp != NULL) {
        fprintf(fp, "We're writing to an SD card!");
        fclose(fp);
        pc.printf("success!\n");
    } else {
        pc.printf("failed!\n");
    }
 
    //Perform a read test
    pc.printf("Reading from SD card...");
    fp = fopen("/sd/sdtest.txt", "r");
    if (fp != NULL) {
        char c = fgetc(fp);
        if (c == 'W')
            pc.printf("success!\n");
        else
            pc.printf("incorrect char (%c)!\n", c);
        fclose(fp);
    } else {
        pc.printf("failed!\n");
    }
 
    //Unmount the filesystem
//     sd.unmount();
}