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: BufferedSerial SDFileSystem
Revision 1:b08afedb843c, committed 2019-04-08
- Comitter:
- JoergWempe
- Date:
- Mon Apr 08 13:02:40 2019 +0000
- Parent:
- 0:fdd58267bc13
- Child:
- 2:6bb642c850bc
- Commit message:
- SD Card at NUCLEO-L432KC
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
nucleo_L432KC.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Apr 07 10:33:54 2017 +0000 +++ b/main.cpp Mon Apr 08 13:02:40 2019 +0000 @@ -1,34 +1,25 @@ #include "mbed.h" +#include "nucleo_L432KC.h" #include "SDFileSystem.h" -//Nucleo L476RG_SDCARD test +//Nucleo L432KC_SDCARD test + +// MOSI, MISO, SCLK, CS, name +SDFileSystem sd(SPI1_MOSI, SPI1_MISO, SPI1_SCLK, SDsel, "sd"); +Serial pc(SERIAL_TX, SERIAL_RX); // TX RX -/* 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() +{ + pc.printf("\nWait for new connection...\n"); - -int main() { - printf("\nWait for new connection...\n"); - mkdir("/sd/mydir", 0777); - printf("\nDirectory created\n"); + pc.printf("\nDirectory created\n"); FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); if(fp == NULL) { - printf("Could not open file for write\n"); + pc.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"); + fclose(fp); + pc.printf("Text written to the SD-CARD\n"); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nucleo_L432KC.h Mon Apr 08 13:02:40 2019 +0000 @@ -0,0 +1,20 @@ + +//UART to AMB8826 +#define TXD1 PB_6 +#define RXD1 PB_7 +#define CTS1 PB_4 +int bautRate = 115200; + +//I2C +#define I2C1_SCL PA_9 +#define I2C1_SDA PA_10 + +//SPI +#define SDsel PA_4 +#define SPI1_MOSI PA_12 +#define SPI1_MISO PA_11 +#define SPI1_SCLK PA_1 + +//ADC +#define Uin PA_6 +#define Ubatt PA_5