code to restart SD card if lost mechanical contact temporarily?

Status
Not open for further replies.

zachtos

Well-known member
I'm having problems where some of our custom designs are losing contact sometimes with the SD card socket, and then audio stops working, but the application keeps running... Cycle power and everything comes back until the next bump.

Is there a simple way in code to detect loss of SD card communication?

and

Is there a way to restart SD card communication if there was a temporary loss of contacts (such as SPI pins etc).
 
Some SD Card sockets have a physical switch to detect the presence of a card. You could hook this up to an S-R latch to detect a missing card. Or you could monitor the activity of the SD Card routine and perforn a time-out if data transfer get hung up. I am also aware of one of the SD Card lines being connected to Vcc thru a resistor but don't remember which one. Perhaps you could find out by looking into SDFAT or your current driver to determine the line used.
 
Thanks, I will try some of those techniques to determine if card lost connection, but if it is a momentary bump, then does anyone have an example of a way to re-start the SD card connection using any of the simple teensy audio examples? Like if I pull the card out while doing the wavfileplayer example, and put back in card, no more sound.
 
I had a similar problem in that I wanted to be able to remove an SD card, edit some files, and place it back in to read without doing a reset. I did some searching and found that a root.close(); is needed in the lib to achieve this. It can be added to the begin() function as shown here, or as a separate end() function as Adafruit did here.
I've edited my Teensy SD lib and verified that it fixes the issue.
Paul- would you consider adding one of these solutions to the Teensy SD lib(s)? Thank you!
 
Status
Not open for further replies.
Back
Top