Tuesday, December 18, 2012

Some SD cards don't like SPI mode and low voltages

It's a sad fact that some SD cards work differently to others.
Although there's a set of "standards" that all (most?) SD cards are supposed to adhere to, the degree of variance between cards is huge.

And we've just wasted about a month trying to fix a problem "properly" instead of doing the pragmatic thing and just hacking a solution together.

A while ago we started adapting some noise-playing alarm clocks. We completely replaced the onboard sound chip with one of our own design, which plays uncompressed wavs from an SD card. It took a lot of working out to get the SD card actually readable and when we thought we'd cracked it, put the audio player board back inside the alarm clock and gave it a try.

Incredibly, it worked first time!
And second time.
And third. But not the fourth.
In fact, after just a few plays, the SD card refused to initialise properly.

It all came down to the supply voltage. At 5v, we put the supply through a voltage regulator to give a steady 3.3v out. Everything worked fine. We put the boards into the alarm clocks and ran them off the 3v that 2xAA batteries created. In truth this was sometimes as high as 3.2v.

After just a few plays, the tiny voltage drop in the batteries was enough to stop the SD card from working.
But that's not where the story ends. Because we've spent about a month trying to use different triggering mechanisms, DC-to-DC converters, opto-isolators, PNP transistors and more yet all the time we had a working prototype on the desk. The circuit was exactly the same, we kept going back to the same (rough-and-ready) firmware. But all the time the prototype worked while every new version didn't.

And then we spotted the difference.
The prototype was using a genuine SanDisk micro sd card. The newer boards were using another brand. And that was enough to make a difference! SanDisk cards are pretty robust and can handle a wide range of supply voltages - cheaper, inferior brands can't.

So after a month of trying to build a circuit which is 100% compatible with all brands of SD cards, we've finally given up. And decided to only support a small sub-set of available cards on the market. It's not ideal. But it'll let us get these bloody clocks made up and shipped, hopefully this time of Christmas!!


No comments:

Post a Comment