0
\$\begingroup\$

I have an FPGA (Lattice ICE40UP5K) at hand and need to do some SD card I/O with it. There are tutorials about interfacing with an SD card with an FPGA, but they typically concern with the case where the card is connected directly to FPGA via some soldering work. However, I want to use an SD card adapter (like this one) for more flexibility, and I'm not sure if these tutorials apply to my use case.

In particular, I wonder what do the adapters do besides exposing the pads of SD cards to jumpers? I have tried hunting for the specification for them, but despite their ubiquitousness, I cannot find any spec for these little adapters :(

Here is a photo of my adapter. From the silk print I can tell they probably speak SPI, but can I just treat the adapted SD card like an SPI flash, without worrying about all the nasty details of the SD card specification? While I have learned that SD cards typically support the so-called SPI mode, the linked article also suggested that "The SPI mode is often used in microcontroller systems. With an FPGA, we might be better served with the SD modes". Which mode should I use with an adapter, then?

enter image description here

For your information, the smaller chip labeled U1 has silk print

LVC125A
WA15508
  TXD19
  05D

the larger chip labeled U (which looks like an analog IC judging from its huge pins) has silk print

AMS1117
3.3 XJS68
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Probably those are designed to interface a 5v Arduino to a card with 3v3 I/O, but without you providing specifications no one can tell you for sure. Realistically, that adapter is not what you want for your project when using it starts with reverse engineering to figure out if it even can be used without modification. Instead, get a simple SD card "breakout". \$\endgroup\$ – Chris Stratton Aug 25 '20 at 15:24
2
\$\begingroup\$

In particular, I wonder what do the adapters do besides exposing the pads of SD cards to jumpers?

The adapter in the pictures also does the 5V->3.3V level translation for 5V arduino. Which is probably not what you want on an FPGA that supports 3.3V I/O directly.

can I just treat the adapted SD card like an SPI flash, without worrying about all the nasty details of the SD card specification

Nope! SD cards power up in SD mode, and must be actively switched into SPI mode (using CMD0). With multiple devices on the SPI bus, you would need to initialize the SD card first before you can treat it as an SPI slave.

Which mode should I use with an adapter, then?

SPI, since the faster SD modes would probably be above the HF frequency limits of your adapter cables.

Note that you could simply "wire" an SD card holder to your FPGA directly, and this could enable you to run at higher SD speed due to a better and shorter signal path.

\$\endgroup\$
1
\$\begingroup\$

Basically the adapter does nothing, except it allows it to be connected to a 5V system (5V supply and 5V IO) such as an Arduino.

Otherwise the protocol how to talk to the card is exactly same, and because of the unidirectional buffer on the adapter, the only supported protocol is SPI.

\$\endgroup\$
4
  • \$\begingroup\$ Can I assume the adapter works with both 5V and 3.3V masters, and that the mapping between adapter pins and card pins follows the “SPI mode” diagram shown here? (You said it can only support SPI, and I suppose it must be wired that way to support SPI) \$\endgroup\$ – nalzok Aug 25 '20 at 16:24
  • \$\begingroup\$ The pin names on the adapter hints about the SPI mode. The product page says it supports 5V and 3.3V masters, but frankly I would not believe anything without seeing the schematics. Also it needs more than 3.3V as the supply input, as it contains an LDO. Unless you find the schematics, I can't tell. \$\endgroup\$ – Justme Aug 25 '20 at 16:30
  • \$\begingroup\$ I see. How do you know there is an unidirectional buffer on the adapter though, just by looking at the photo I posted? It would be awesome if you could point out its location! \$\endgroup\$ – nalzok Aug 25 '20 at 16:32
  • \$\begingroup\$ U1 is a 74LVC125 buffer. These are generic adapters available from everywhere. \$\endgroup\$ – Justme Aug 25 '20 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.