Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: code to restart SD card if lost mechanical contact temporarily?

  1. #1
    Senior Member
    Join Date
    Aug 2014
    Posts
    143

    code to restart SD card if lost mechanical contact temporarily?

    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).

  2. #2
    Senior Member
    Join Date
    Nov 2015
    Location
    Cold hollow VT
    Posts
    177
    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.

  3. #3
    Senior Member
    Join Date
    Aug 2014
    Posts
    143
    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.

  4. #4
    Junior Member
    Join Date
    Dec 2017
    Location
    Oregon, USA
    Posts
    7
    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!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •