SD card module for 5V microcontrollers - please explain this one - Page 1
Forum section: electronics / projects

author: Peabody
author_rank: Super Contributor
timestamp: August 05, 2019, 05:06:45 am
content: When you look for modules for connecting standard size SD cards to microcontrollers, you find modules that look like this:https://www.jaycar.com.au/arduino-compatible-sd-card-interface-module/p/XC4386And notice that it says "Features 5V and 3.3V power inputs and resistors to allow safe on either IO voltage."I think that's nonsense, and these modules should be used only with 3.3V controllers, not Arduino Unos and Nanos running at 5V.Attached are a closeup of the module and what I believe to be its schematic. The resistors are pullup resistors to 3.3V, but there are no series resistors or voltage dividers for the controller's three 5V SPI outputs, and their full 5V is applied to the SD card pins. SD cards are 3.3V devices. The module's regulator provides the correct 3.3V Vcc to the SD, but the I/O pins are blasted with 5V, which I would just guess exceeds the absolute maximum value for these pins.If the SD card pins have protection diodes to Vcc, then current will flow out of the controller's I/O pins without limit until the output voltage drops to about 3.9V. No telling how many milliamps that might be. And at least in theory, remembering Dave's video on this idea, if enough current flows through the protection diodes to fully supply the power needs on the Vcc pin, voltage could continue to rise on Vcc up to 4.4V, which again would violate the absolute maximum value. I suppose it's possible that some SD cards have 5V-tolerant pins, but I haven't seen any indication of that in datasheets.By contrast, modules for *microSD* cards have level shifting I/Cs to deal with the 5V issue.These full-size SD modules are widely sold everywhere and are touted as being suitable for 5V controllers. I just don't understand how that could be. And apparently these modules do actually work with some SD cards, at some speeds. So what am I missing here? If the schematic is correct, how can these work with 5V controllers?

author: Psi
author_rank: Super Contributor
timestamp: August 05, 2019, 05:27:16 am
content: You could use it with a 5V ATmega using software SPI and switching between output low and input floating.That way you would never be feeding 5V to it.You would simply send data by toggling between low or using the 10k pullup.The AVR IO port registers are designed so you can do this.You set PORTA low and then just use DDRA for data,DDRA high = output lowDDRA low = Input float (SD card board pullup used to become 3v3 high)I don't think there is a way to do this using hardware SPI though.

author: magic
author_rank: Super Contributor
timestamp: August 05, 2019, 08:34:02 am
content: Well...One time I accidentally supplied an SD controller with 5V instead of 3.3V and inserted a 2GB card. Both the controller and the card worked until I noticed my mistake and powered them down. They are still alive.So my guess is that at least some cards (maybe older ones) may be tolerant (at least for some time) and that's why they sell those things and many noobs likely use them wrong by supplying full 5V but things don't blow up immediately so it's "OK".Then somebody made a micro version and noticed that some newer cards blow up immediately so they added level shifters.And another story: a USB card reader stopped working after a while. I took it apart and found that instead of 3.3V regulator, they used a series diode from USB 5V line to the chip's VCC, giving about 4.3V on the chip's and card's VCC. Somebody saved a penny, but it didn't last

author: Peabody
author_rank: Super Contributor
timestamp: August 05, 2019, 05:56:03 pm
content: Psi, do you suppose there is a library that does software SPI as you describe specifically for use with these modules? That would be nice to have since standard-size SD modules with level shifters don't appear to be available.magic, I guess what surprises me most is that these modules actually work some of the time. Apparently some SD cards just tolerate the 5V with little problem, at least until the speed gets too high.

author: amyk
author_rank: Super Contributor
timestamp: August 05, 2019, 08:05:27 pm
content: A lot of 3.3V CMOS processes have 4.6V absolute maximum ratings. That's within -10% of 5V that, given a below-spec 5V supply and natural process variation, the device may be able to survive for some time at that voltage, but it's definitely not recommended and many will die.(Unfortunately, the specifics of device reliability vs. supply voltage for a given process is notoriously difficult to find. Manufacturers seem to like leaving such things unsaid.)

author: magic
author_rank: Super Contributor
timestamp: August 05, 2019, 09:41:27 pm
content: A simple hack that may work: place Schottky diodes such that the MCU can pull SCK and MOSI down but only pullup resistors pull it up. This will give 0.3V low state output voltage, sensible 3.3V logic should interpret it as low.Check "minimum input high voltage" of your MCU. If you are lucky, 3.3V will register as high in the MCU running at 5V, so MISO can simply be wired from a 3.3V card straight to the chip.

author: Peabody
author_rank: Super Contributor
timestamp: August 06, 2019, 04:00:29 am
content: Quote from: magic on August 05, 2019, 09:41:27 pmThe diode would work for the CS output too. While there is no pullup for that line on the module, there is one inside the SD card, nominally 50K. And I guess you could solder the three diodes between the module header pins and the SD card pins then cut the existing traces coming off the headers.Bringing MISO in to the processor at 3.3V does work. All the microSD modules do that, and it seems to work fine. Schematic attached.

author: Psi
author_rank: Super Contributor
timestamp: August 06, 2019, 04:08:36 am
content: Quote from: Peabody on August 05, 2019, 05:56:03 pmEntirely possible.If there is one it's going to be an arduino library.I don't really use arduino so i dunno.

author: Peabody
author_rank: Super Contributor
timestamp: August 08, 2019, 02:32:35 am
content: magic,I modified my module to add in the three diodes on MOSI, CLK and CS, and tested it with a Nano running the CardInfo and ReadWrite example sketches. I used standard 1N914/1N4148 signal diodes, and it all worked fine. Of course that doesn't mean it would work at speed, or with every SD card, and as you say, Schottky diodes would be the more appropriate choice. But it's encouraging that regular diodes work in these cases at least.This is a lot of trouble to go to, and if there's room for it, adding a level-shifting I/C would be the better choice.Anyway, attached is a picture of my mod.

author: magic
author_rank: Super Contributor
timestamp: August 08, 2019, 06:33:39 am
content: I would put them at the bottom to avoid messing up the connectors. There are SMD diodes which wouldn't even protrude from the board any more than those connector pins already there.Silicon diode may possibly be enough and even Schottky may possibly be not enough, it all depends on what voltage are SD cards required by the standard to definitely register as "low". Problem is, I couldn't find this information right away so I just said "Schottky".So you can confirm that those example codes that you used and presumably everybody else uses too normally would run the card at 5V?

author: jonovid
author_rank: Super Contributor
timestamp: August 08, 2019, 07:03:15 am
content: this pcb SD Card Interface is only for 3.3Vyou need the 5 voltmicroSD Card Interface! for most arduinos or mod your arduino to run 3.3Vupdate-LVC125A WA1552.3 TXD19 05D 14 pin/leghttp://www.ti.com/lit/ds/symlink/sn74lvc125a.pdfmicro SD and the micro SD card Interfaces use this chip.I can not find the schematic diagram for this Interface pcb.- full-size SD cards and the full-size card Interfaces are now obsolete but still in use.

author: Peabody
author_rank: Super Contributor
timestamp: August 08, 2019, 02:39:14 pm
content: Quote from: magic on August 08, 2019, 06:33:39 amYes, I think you might be able to cut the traces on the bottom, and solder the SMD diodes across the cuts. But you would have to be very careful because ground is very close by. I used regular diodes because that's what I had.QuoteI agree. But I think the preferred solution is to use a level-shifter I/C instead of the diodes. That would take you all the way to ground, with no speed issues.QuoteIf the Arduino is powered at 5V, then the I/O lines going to the SD card are 5V using this module. But I did not test the module before modding it. Just didn't want to risk it.

author: Peabody
author_rank: Super Contributor
timestamp: August 08, 2019, 02:41:05 pm
content: jonovid, here's a schematic for the typical microSD module with the 125A level shifter.

author: Peabody
author_rank: Super Contributor
timestamp: August 09, 2019, 10:56:10 pm
content: Martin Prescott on the Arduino Forum found a source for standard size SD card modules with level-shifting I/Cs:https://www.dx.com/p/sd-tf-card-adapter-module-for-arduino-3-3v-5v-compatible-multi-functional-reading-writing-module-2044018