Nucleo-L476RG using SD-CARD library. The program is functioning but might get problem if you update the mbed. In two different times I got problem with mbed library as no SPI clock was generated. At the time I publish this library the mbed is broken.

Dependencies:   SDFileSystem

Files at this revision

API Documentation at this revision

Comitter:
mjm2016
Date:
Fri Apr 07 10:33:54 2017 +0000
Commit message:
Reference code for testing SD-Card with MBED-OS. ; The SD-Card works with this revision, but updating MBED-OS might cause problem. I can confirm that the current mbed-rev at 2017-04-07 is broken. ; Use this sample code as reference

Changed in this revision

SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r fdd58267bc13 SDFileSystem.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Fri Apr 07 10:33:54 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/SDFileSystem/#8db0d3b02cec
diff -r 000000000000 -r fdd58267bc13 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Apr 07 10:33:54 2017 +0000
@@ -0,0 +1,34 @@
+#include "mbed.h"
+#include "SDFileSystem.h"
+//Nucleo L476RG_SDCARD test
+
+
+
+/*              SD:                Description             nucleo           PINNR (from top to down of the right-connector-left pins):
+                1                   CS                     PB_6              9  
+                2                   MOSI                   PA_7              8
+                3                   GND                    GND
+                4                   3.3V                   3.3V
+                5                   SCLK                   PA_5              6                  
+                6                   -
+                7                   MISO                   PA_6              7
+                8
+                
+*/
+//              MOSI, MISO, SCLK, CS, name
+SDFileSystem sd(PA_7, PA_6, PA_5, PB_6, "sd");
+
+
+int main() {
+    printf("\nWait for new connection...\n");
+    
+    mkdir("/sd/mydir", 0777);
+    printf("\nDirectory created\n");
+    FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
+    if(fp == NULL) {
+        printf("Could not open file for write\n");
+    }
+    fprintf(fp, "Hello fun SD Card World!");
+    fclose(fp); 
+    printf("Text written to the SD-CARD\n");
+}
diff -r 000000000000 -r fdd58267bc13 mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Fri Apr 07 10:33:54 2017 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#34c1facf42a174f47fdf9002cd8c6bf10ac41744