9 years, 2 months ago.

problem interfacing MBED with SDFileSystem

Hi,

I have problem with SDFileSystem. uSD card is connected to SPI. Everything is working fine after hard reset of the MBED. But if I switch off and on power, MBED starts blinking (two middle LEDs, then two outside LEDs) and does not write to uSD. Then if I reset it using the button, everything goes fine again.

When I was lucky to connect terminal before MBED hangs, I saw the message: "No disk, or could not put SD card in to SPI idle state Didn't get a response from the disk Set 512-byte block timed out Could not open file for write"

I tried initial delay of some seconds before initialization of SDFileSystem object, but it did not help.

Does anybody solve this problem?

I also could not find the description of this blinking. Where I can find documentation of mbed library? (especially for functions like debug(...), debug_if(...), error(...) )

That is the dead MBED blink, it's a generic indication of some fatal error. The most common cause is trying to create an invalid pin assignment (e.g. a serial port on non-serial port pins). Clearly that's not the case here since it's intermittent. No idea at all why you are getting this, if it was power up related a short delay should fix it.

posted by Andy A 02 Mar 2015

If you're still having issues, could you post/publish your code? That will help us solve your problem

posted by Brian Daniels 20 Mar 2015

I found the problem. It was

FILE *fp = fopen("/sd/data02.txt", "a");
    if(fp == NULL) error("Could not open file for write\n");

As I understand, the uSD card need some time to power up and first fopen call returned NULL, causing error(), which blinked LEDs.

That was my second part of the question: Where I can find documentation of mbed library? (especially for functions like debug(...), debug_if(...), error(...) ) I could not find it in mbed.org

posted by Peter Kravtsov 21 Mar 2015

Hi Peter,

So sorry for the delay! I don't believe these parts of the library are documented on mbed.org because they are mostly internal functions. If you're curious how they work I would recommend checking out the source on github.

Here are a few useful links:

https://github.com/mbedmicro/mbed/blob/43d7f387ec8e6fef8c03cb5e3a74f7b1596c8f8c/libraries/mbed/api/mbed_debug.h

https://github.com/mbedmicro/mbed/blob/43d7f387ec8e6fef8c03cb5e3a74f7b1596c8f8c/libraries/mbed/api/mbed_assert.h

https://github.com/mbedmicro/mbed/blob/43d7f387ec8e6fef8c03cb5e3a74f7b1596c8f8c/libraries/mbed/api/mbed_error.h

All of the functions are pretty well documented in the code.

Hope this helps! -Brian

posted by Brian Daniels 17 Apr 2015

Thanks, Brian! This is what I wanted to see!

posted by Peter Kravtsov 18 Apr 2015
Be the first to answer this question.