Reset Button vs Powering Mbed

30 Apr 2012

I am building a logger with an SDHC card to store sensor data, I am using the SDHCFileSystem library. I simply use FILE *fp = fopen(filename, "a"); at the top of main. filename is built from a timer.

My problem is that when I shutdown and restart the system, most of the time (not always!) the SD card does not initialize automatically. I need to physically push the reset button, then it works.

I tried the mbed_reset() function at the top of main, but the Mbed main LED starts blinking and nothing happens. I pulled nR to low, then back to high, but the SD card does not init.

My questions are: - what is different between pulling the plug (USB or Vin), and reseting with the button? - How can I consistently reset on restart in order to start the SD card? - Is this a problem with Mbed, or rather a timing issue in the SDHC library?

Thanks for any hint you may have.

30 Apr 2012

Maybe it is a timing issue. I had the same problem with a SD card but when I switched to another card, the problem went away. I could never get the mbed to talk to the card right after the device was given power but a reset always fixed the issue.

I took the easy route though! Switched cards rather than trying to debug and root cause the problem :)

01 May 2012

Thanks,

that's what I found also, not every card works the same. The situation is improved by using 10K resistors between MOSI/MISO lines and the card, and adding a 0.1uF capacitor for Vcc. Now, and with a different card the system seems to work.

However, for added safety I would like to implement a soft reset (matching the push of the button) upon restart.

01 May 2012

Frederic Drago wrote:

I tried the mbed_reset() function at the top of main, but the Mbed main LED starts blinking and nothing happens. I pulled nR to low, then back to high, but the SD card does not init.

Wouldn't this just keep the device in a reset loop or did you have a way to break out of the loop?

01 May 2012

You are right for the infinite loop, I re-wrote the simple routine and it is apparently working for all cards I have.

.....

extern "C" void mbed_reset();
int main(void) {

.....
    FILE *fp = fopen("/sd/hello.txt", "a");

    while (NULL == fp) {
        mbed_reset();
        wait(0.1);
        FILE *fp = fopen("/sd/hello.txt", "a");
        wait(0.1);
    }
    
    while (1) {
.....