7 years, 5 months ago.

How to use SDFileSystem ?

How do I use the SDFileSystem library in the STM32F303K8 boards?

I can build code, but doesn't work well.

F303K8 - uSD

A6 -> CMD

A5 -> DAT0 (Pull-up)

A4 -> CLK

A3 -> CD/DATA3

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F303K8T6 microcontroller.

Hi Mick :),

Can you post your code here and also outline what exactly is the issue?

Regards,

Andrea, team mbed

posted by Andrea Corrado 31 Oct 2016

Hi Andrea,

My code is very simple as below. Only outputs failure message.

main.c

#include "mbed.h"
#include "SDFileSystem.h"

//------------------------------------
// Hyperterminal configuration
// 9600 bauds, 8-bit data, no parity
//------------------------------------

SDFileSystem sd(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, "sd");
Serial pc(SERIAL_TX, SERIAL_RX);
 
DigitalOut myled(LED1);
 
int main() {
    int i = 1;
    pc.printf("Hello World !\n");
    for (int i=5; i>0; i--) {
        wait(1);
    }
        
    FILE *fp = fopen("/sd/test.txt", "r");
    wait(2);
    if (fp != NULL) {
        pc.printf("fopen success\n");
    } else {
        pc.printf("fopen failure\n");
    }
    
    while(1) { 
        wait(1);
        myled = !myled;
    }
}

Regards,

posted by mick omori 01 Nov 2016
Be the first to answer this question.