Author Topic: SD card module for 5V microcontrollers - please explain this one  (Read 9642 times)

0 Members and 1 Guest are viewing this topic.

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2398
  • Country: us
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/XC4386

And 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?

 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10514
  • Country: nz
Re: SD card module for 5V microcontrollers - please explain this one
« Reply #1 on: August 05, 2019, 05:27:16 am »
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 low
DDRA 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.
« Last Edit: August 05, 2019, 05:29:32 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 7571
  • Country: pl
Re: SD card module for 5V microcontrollers - please explain this one
« Reply #2 on: August 05, 2019, 08:34:02 am »
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 :palm:
« Last Edit: August 05, 2019, 08:39:53 am by magic »
 
The following users thanked this post: electrode

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2398
  • Country: us
Re: SD card module for 5V microcontrollers - please explain this one
« Reply #3 on: August 05, 2019, 05:56:03 pm »
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.
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8644
Re: SD card module for 5V microcontrollers - please explain this one
« Reply #4 on: August 05, 2019, 08:05:27 pm »
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.)
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 7571
  • Country: pl
Re: SD card module for 5V microcontrollers - please explain this one
« Reply #5 on: August 05, 2019, 09:41:27 pm »
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.
 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2398
  • Country: us
Re: SD card module for 5V microcontrollers - please explain this one
« Reply #6 on: August 06, 2019, 04:00:29 am »
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.

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

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10514
  • Country: nz
Re: SD card module for 5V microcontrollers - please explain this one
« Reply #7 on: August 06, 2019, 04:08:36 am »
Psi, do you suppose there is a library that does software SPI as you describe specifically for use with these modules? 

Entirely possible.
If there is one it's going to be an arduino library.
I don't really use arduino so i dunno.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2398
  • Country: us
Re: SD card module for 5V microcontrollers - please explain this one
« Reply #8 on: August 08, 2019, 02:32:35 am »
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.
« Last Edit: August 08, 2019, 02:35:42 am by Peabody »
 
The following users thanked this post: Cichero_Gabriel

Offline magic

  • Super Contributor
  • ***
  • Posts: 7571
  • Country: pl
Re: SD card module for 5V microcontrollers - please explain this one
« Reply #9 on: August 08, 2019, 06:33:39 am »
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? :-DD
« Last Edit: August 08, 2019, 06:37:05 am by magic »
 

Offline jonovid

  • Super Contributor
  • ***
  • Posts: 1593
  • Country: au
    • JONOVID
Re: SD card module for 5V microcontrollers - please explain this one
« Reply #10 on: August 08, 2019, 07:03:15 am »
this pcb SD Card Interface is only for 3.3V
you need the 5 volt micro SD Card Interface! for most arduinos   or mod your arduino to run 3.3V   :-//
 update-
LVC125A   WA1552.3  TXD19   05D    14 pin/leg
http://www.ti.com/lit/ds/symlink/sn74lvc125a.pdf
micro 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.
« Last Edit: August 08, 2019, 10:43:05 am by jonovid »
Hobbyist with a basic knowledge of electronics
 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2398
  • Country: us
Re: SD card module for 5V microcontrollers - please explain this one
« Reply #11 on: August 08, 2019, 02:39:14 pm »
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.
Yes, 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.

Quote
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".
I 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.

Quote
So you can confirm that those example codes that you used and presumably everybody else uses too normally would run the card at 5V? :-DD
If 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.
 

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2398
  • Country: us
Re: SD card module for 5V microcontrollers - please explain this one
« Reply #12 on: August 08, 2019, 02:41:05 pm »
jonovid, here's a schematic for the typical microSD module with the 125A level shifter.
 
The following users thanked this post: bitseeker

Offline PeabodyTopic starter

  • Super Contributor
  • ***
  • Posts: 2398
  • Country: us
Re: SD card module for 5V microcontrollers - please explain this one
« Reply #13 on: August 09, 2019, 10:56:10 pm »
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

 
The following users thanked this post: edavid, bitseeker


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf