7 years ago.

SD Card dosent work again/ NUCLEO L476RG /OR NUCLEO F030R8

Hi, I had my project running with the code I have. I didn't change anything of the code or the hardware. But it doesn't work. I probed the data IO from the SPI .. nothing happened (MSIO, CLK, MOSI) What did you change in the last past month to make the code not working? Please MBED development group answer this question.. It is not good, when you have a working code, after some time you get suddenly problem with something that it shouldn't be a problem. Don't you test the code? For about 1,5 month, my code was working ..I don't know which code is changed that cause the problem. Thanks Regards

include the mbed library with this snippet

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

//DigitalOut myled(LED1);
//              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);
    
    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); 
    
    while(1) {
        /*
        myled = 1;
        wait(1.2);
        myled = 0;
        wait(1.2);*/
    }
}

I was using this https://developer.mbed.org/users/mbed_official/code/mbed-dev/ version of mbed

Can you post your code ? Please use the <<code>> before your code and <</code>> after your code for proper formatting. Which version of mbed are you using that works ? Which version of the mbed breaks the code ?

If the PA port pins are not working at this time, can you try the following ?

SDFileSystem sd(PB_5, PB_4, PB_3, PB_6, "sd"); MOSI, MISO, SCLK

Do you see activity on the SPI1_SCK pin PB_3 ? We are interested in the QSPI support which is available on this micro so may consider to bring in this board and review the same details. To clarify, you have not seen the SPI port work with this target board and the recent mbed version ?

Based on the following google search, Everspin has a demo board based on their MRAM products (which look quite nice and worth a review) and this shield mates with the same Nucleo board and also uses the same port pins as shown in your posted code. So there is hope :) Can you import their posted mbed code as they indicate in their documentation -> compile and then monitor again the SPI1_SCK pin (same pins as in your source code). You may need to slow down the SPI CLOCK for your external device but the interest for now is to just see if you can see activity on the SPI port pins.

https://www.everspin.com/evaluation-board-serial-peripheral-interface-spi-mram-products

https://www.everspin.com/file/578/download

https://www.everspin.com/file/574/download

Summary: If the same kit, same port pins, with mbed can function with the Everspin project then it should be possible to work for yours as well. One concern is that the SPI1_xx port pins are requiring the shorting blocks (0 ohm resistors) under the PCB to be soldered. Believe these are already present from the factory but do check that you have 0 ohm resistors on SB40, SB41, SB42. These shorting blocks allow for the PA5, PA6, PA7 from the CPU to be available onto the external pads on the Nucleo board.

posted by Sanjiv Bhatia 06 Apr 2017

You have the code. It was working before. But now, SPI clock is not generating and the library doesn't work

I tried again this old sample code which you find at

https://developer.mbed.org/users/xxwiz/code/Nucleo_F030R8_SD/

It is working .. but that old mbed doesn't include support for my new Nucleo board. I tried the code mentioned here with the old board and the SD card still works.

posted by M J. 06 Apr 2017

Hi again, I tried this

SDFileSystem sd(PB_5, PB_4, PB_3, PB_6, "sd"); MOSI, MISO, SCLK

I get the same error. As evidence, I tried exactly the same code I have in the project but different mbed.

  • 1-Mbed Rev : 78:ed8466a SDCard library Rev : 2:c8f66dc : Both comes with the sample code mentioned for F030R8 : It works.
  • 2-Mbed Rev : 161:2cc1468 SDCard library Rev : 2:c8f66dc : Updated MBED-DEV It dosent work. for F030R8

So, the problem is not the platform .. it is MBED ..

I used the newer platform I have (nucleo l476rg) with the SD-Card and it was working before .. I coulnd't work on my project for the last month .. And after updating the mbed, I cannot reach the SD longer. So the problem is what did MBED team change that affect the SPI for all platforms, not just for L476RG

I am quite sure that MBED has got a bad code. There is no clk out from the same pin if I use the older mbed I get the clock pulses. The only difference in this setup is the MBED version. Please try to find out the problem. I cannot get older MBED-DEV version .. say about 1 month ago .. to test it again ..

posted by M J. 07 Apr 2017

IMPORTANT: I found the broken revision

Using MBED-OS and going back to REV 34C1FAC 16 JAN 217, the SD-Card is working .. Please look at the changes you made .. This will help us to find out the problem and fix it ..

I used the same code as I mentioned, I updated the SD-Card to the official version and it is for the board Nucleo L476RG which I compiled to.

You find a working project at

https://developer.mbed.org/users/mjm2016/code/Nucleo_L476RG_SDCard_WorkingSample/

posted by M J. 07 Apr 2017

3 Answers

5 years, 12 months ago.

Hi, I had the exact same code. I managed to make it work by increasing the voltage to 5V, instead of using 3.3V

5 years, 9 months ago.

hi

just use pin number as PTE1 ,PTD1

5 years, 9 months ago.

hi