Posted on

Reliance

It’s one thing to know you can potentially use a “card detect” feature on a micro SD card connector.  It’s a whole different ball game when something goes wrong with it.  Take the above for example, an Adafruit micro SD card reader that I’ve had a little over a month now.  The card detect pin worked as it should, closed when there was no card present and open when I inserted one.  However, I soon started noticing some issues with it.

For one, the switch would open as a card was being slid in, as opposed to when it’s locked into place (and therefore available to be read from.)  While this may very well be the design of it, it posed a small problem for my design.  I was hoping to use it to trigger the code to react on it, however you can’t start using the card till it is actually locked in place, which isn’t what happens when that switch goes open.  So that’s problem number one.

Second, I started noticing at times the switch would remain open even after removing the card.  Or just wiggling the card itself would cause the switch to open and close sporadically …  Imagine if your code is meant to react to it opening or closing, and suddenly it changes states like that.  That would cause havoc on the code side.  And while I could potentially incorporate some debounce for it, how do you really make sure it works.  Check once, wait a second, and try again?  And because this works via the SPI bus, it already takes about 1-3 seconds to timeout.  So I could just loop it again and again, but then who’s to say it won’t just get stuck and/or crash.  Not a good design of course.

So for now, I’ve decided to ignore the card detect switch, at least till I can find a more robust connector.  For now the code will look for one thing: did it initialize?  It’s a simple ‘yes’ or ‘no’ state.  Either it works or it doesn’t, regardless of what the problem might actually be.  This isn’t ideal, but it will have to do for this specific revision.