SD Card 5v to 3.3v level shifting for AVR

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've got two SD Card modules with onboard 5v to 3.3v conversion however they are implemented quite differently.  They both have 1117 LDO regulators for 3.3v.  One uses a level shift IC on the data lines while the other just has a bunch of 10k resistors.  Are there implications of one method vs. the other?  I need to run the AVR at 5v.  Thank you.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Rooney wrote:
Are there implications of one method vs. the other?
Yes

Planet Analog - Articles - SIGNAL CHAIN BASICS #66: How to interface a 5V transceiver to a 3V controller

(mid-page)

Figure 5. Using a single current-limiting resistor causes damage to the input circuitry.

10K ohm is high for SPI (a few ns rise-time); 1K might work though half that is better.

mega4809 Curiosity Nano has LVC1T45 to translate from 3V SAMD21 to 5V mega4809.

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


gchapman wrote:

 

Planet Analog - Articles - SIGNAL CHAIN BASICS #66: How to interface a 5V transceiver to a 3V controller

(mid-page)

Figure 5. Using a single current-limiting resistor causes damage to the input circuitry.

 

 

What about the WIZNET Ethernet Shield where that limiting resistor is zero ohm ?

 

While from 5 to 3.3V can be hacked with a resistor or a resistor divider, the MISO signal encounters other issues. 3.3 / 5 = 0.66 while Mega4809 requires 0.7 of 5V.

In fact, while Wiznet advertises their board as 3.3 / 5V compatible here 

down the page they say:

The reason it is working, they rely on the fact that most of the time Arduino Uno is powered from an USB port, so the 5V is in fact 4.3 or slightly higher and therefore 3.3V is enough to slightly exceed the minimum threshold.

They remove the active buffers out of concern that the buffers introduce additional delays for the SPI communication. I wonder if a barely exceeding MISO signal does not introduce a delay as well. 

 

I would go with the board on the left in that picture. Few ns introduced by those buffers are not going to have an impact for a maximum of 10MHz that you can get our of your Mega4809.

 

The reason they use simple resistors instead resistor dividers is to have it compatible with both 5V and 3.3V.

 

I am curious in this case, why 5V is not avoidable if OP could share some light.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

angelu wrote:
What about the WIZNET Ethernet Shield where that limiting resistor is zero ohm ?
WIZnet W5500 is 5V tolerant.

Any 5V-tolerant SD cards?

A 1117 doesn't have significant reverse current (out to in) so the 5V AVR could over-volt the SD card's power (therefore, current limiting resistors on the signals)

A 1117's datasheet may have conditions to add the reverse diodes.

 

iEthernet W5500 Datasheet kr

(bottom of page 2)

- 3.3V operation with 5V I/O signal tolerance

A 5V-tolerant USB UART :

XR21B1420 Data Sheet

(page 59)

Application Circuits

The GPIO inputs are 5V tolerant. However, when GPIO input voltage levels exceed VCC, an external clamp circuit is required. Two examples of different application circuits are shown in Figure 7.

...

Figure 7: VCC Clamp Circuits

via XR21B1420 - MaxLinear

NCP1117LP - 1.0 A Low-Dropout Positive Fixed and Adjustable Voltage Regulators

(page 11)

Protection Diodes

[drain the output and Adj capacitors]

...

via NCP1117LP: Linear Voltage Regulator, Positive, LDO, 1.0 A (Fixed and Adjustable)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Rooney wrote:
One uses a level shift IC on the data lines while the other just has a bunch of 10k resistors.
A level shifter can reach 20Mbps or greater.

One SD card :

  • I/O capacitance is 10pF max
  • 25MHz clock therefore 10ns max rise-time

10K resistors means a greatly reduced SPI clock frequency.

An AVR's SPI rise-time is a few ns.

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

angelu wrote:
I am curious in this case, why 5V is not avoidable if OP could share some light.

 

Absolutely.  This project's sole purpose is to communicate with other devices which are 5v only.  Lots of 5v IO lines and the SD Card is the only non 5v component.  Thank you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Rooney,

I'm using the SD card module on the right in post 1.  I'll post a scope picture of the clock waveform from the controller at 4MHz when I get the diode adaptor built.

 

Alan

Last Edited: Sun. Apr 14, 2019 - 06:16 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gchapman wrote:

 

A 1117 doesn't have significant reverse current (out to in) so the 5V AVR could over-volt the SD card's power (therefore, current limiting resistors on the signals)

A 1117's datasheet may have conditions to add the reverse diodes.

 

 

You mean current sink capability ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No

1117's pass transistor can be damaged.

There are a relative few voltage regulators that are two quadrant (current source and current sink)

 

A rugged replacement for a 1117 (reverse leakage is approximately 100micro-amp nominal)

LT3088 Datasheet and Product Info | Analog Devices

...

  • Pin Compatible Upgrade to LT1117
  • Reverse-Battery and Reverse-Current Protection

...

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

I'm back to post pictures of waveforms for the LC Soft SD Card (one on the right in post 1); however, nothing went as planned.  If you are not interested in the details, my conclusion is to forget about using diodes with this particular set of parts and use a level shifter.  Place a 100 ohms resistor between the microcontroller and level shifter for MOSI, SCLK, and CS.  Include a 100 ohm resistor between the SD Card and level shift for MISO.

 

The Diode-based level adaptor

Soldered a diode between two,2 inch leads and crimped connectors at each end:cathode facing the 5v microcontroller .  Connected 5v power to the LC Soft SD card module  and the diode-embedded  lead between the SCLK pin on the microcontroller and CLK pin on the SD Card.  What a crummy waveform:

Top trace is located at the SD Card, bottom trace at the output of the controller. Each trace has a vertical scale of 2v/div; horizontal scale is 0.2us/div

As you can see, the card voltage never gets above 2 volts.

 

Before going farther, I need to qualify the ringing that you see at the microcontroller's output. A few days ago when I first viewed the clock output of the microcontroller with no load, the waveform was a very clean square wave. During wiring changes yesterday, I must have messed up somewhere because the board's voltage regulator got very hot to the touch.  I replaced the ATtiny861 today with a spare but the waveform did not clean up so my problem must be elsewhere.

 

So I replaced the diode adapter with a level shifter from Sparkfun. https://www.sparkfun.com/product... and wired it between microcontroller and SD Card. Ringing became more pronounced.

After learning more about the Sparkfun level shifter,  I concluded that the gate to source capacitance of the FET (27pf for the BSS138) must be allowing the input to the level shifter to bleed through to its output. To limit that affect, I placed a 100 ohm resistor between the controller's output and the level shifter. 

That helped to the point where I can proceed but I also plan on tracking down the board's problem.  Yes, I have a 0.1uf ceramic capacitor between power and ground on the tiny861 as well as before and after the regulator. I even placed a set of caps across the high and low level voltage pins in the level shifter - had no affect.

 

Hope this information helps someone.

Alan

 

Edits: many . .  can always be improved

Last Edited: Wed. Apr 17, 2019 - 12:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just using 1K8 and 3K3 resistor to drop from 5V to 3v3 and then relying on the MISO pin to read the 3v3 swing output is not "in spec".  However I can say that thousands of devices have been made that do just that and they are fairly reliable.

 

If you are paranoid you can get a 74LVC1T45 in a SOT23-6 package for that one signal.

 

It just seems a bit dumb to use a FET based bi-directional translator like the spark fun one to convert signals that are one way only.  That sparkfun thing is a solution for I2C.  I2C runs at 400Khz mostly.  SPI on an SD card can run up to 25Mhz.