3.3v <> 5v interfacing @ 15Mhz

Hi,

Please may I ask for assistance? I need a reliable method of interfacing an SPI SD/MMC card to a dsPIC. At the moment I'm using a 1k8/3k3 voltage divider on the 5v ----> 3.3v signals, and connecting the 3.3v ----> 5v signals straight to port.

It's working ok upto about 3-5Mhz, with anything above 7.5Mhz causing misread bits. Here's the actual signals;

dsPIC --------------- SD/MMC CLOCK (5v) ----> CLOCK (3.3v) SPI OUT (5v) ----> DATA IN (3.3v) CHIPSEL (5v) ----> CS (3.3v) SPI IN (5v)

Reply to
Alison
Loading thread data ...

x-posted to s.e.d. where you are likely to get answers.

The divider you have should work fine at those speeds, with the caveat of track length and signal capacitance. Have you looked at the signals with a scope (using a 10x probe)?

If you use buffering, simply get 3.3V devices with 5V tolerant inputs (all the usual suspects make them) or use transmission gates for the path from the processor to the MMC/SD card. I am using some TI devices in an SDIO implementation but that's because I have bidirectional data lines.

As to the Card -> processor lines, and without looking at the DSPic datasheet, what is the Vih spec for the DSPic inputs? If they are true CMOS, then 3.3V is at the lowest Vih (2/3 Vcc). If they _are_ CMOS, then you'll need to translate those as well - use a 5V device with TTL level inputs.

Cheers

PeteS

Reply to
PeteS

You have effectively supplied 3.3 V through about 1k. The chip uses more current as the frequency increases, thus dropping the supply voltage. You would be better off using an emitter follower to supply the current, driving it from that divider with a diode added for Vbe and thermal compensation.

--
Chuck F (cbfalconer at maineline dot net)
   Available for consulting/temporary embedded and systems.
Reply to
CBFalconer

You don't say exactly where you are putting the resistors. They should work fine in the paths that are inputs to the 3 volt SD card. But when you are driving out from the 3 volt SD card to the5 volt PIC, the resistors won't boost your voltage up! You should be able to drive the PIC directly from the SD card DATA OUT without resistors. Your problem is not speed per se, but rather voltage level.

I have never figured out exactly what is going on in most CMOS interfaces. They often spec them like they are TTL when they are really symetrical CMOS. To see if your design will work without buffers you need to check the input and output voltage levels on the two devices and see if they are compatible. Even if you can get it to work on your bench, if you have too little noise margin it can fail in the field when the temperature changes or the PSU ages and the supply voltage changes.

I took a look at the dsPIC33F and it uses CMOS input specs of 0.2/0.8 x Vdd, but TTL output specs of 0.4/2.4 volts. Their input and output specs are not compatible with itself! With a 5 volt supply the input high threshold is 4 volts, so you don't have a hope of meeting this with a 3.3 device. You will need 5 volt buffers with TTL level input voltages.

It also says this part uses a 3.3 volt only supply. So something is rotten in Denmark. Why are you using 5 volts on the dsPIC in the first place? I see that the dsPIC30 will work up to 5 volts. Why not use a

3.3 volt part instead?

Alis> Hi,

Reply to
rickman

Hi Pete, thanks for your reply

I'll try to get the scope back this weekend. I've been using a logic analyser for almost everything in this project.

Nods

The ports are ST: Schmitt Trigger input with CMOS levels. ViH is... 0.8v

So it should be fine. But.. I have a 100 Ohm resistor on the 3.3v DATA OUT line which connects in series to the dsPIC input port. If I do not do this then communication becomes even more unreliable. Most of the diagrams on the net do not have any kind of buffering on this line. I added it as a guess.

My plan of action today is to build a piggyback board to go inbetween the dsPIC and main breadboard. The purpose of this is to reduce the uncertainty as much as possible. The SD card will be within about 1cm of the dsPIC rather than about 10cm away as at present on the end of solid signal wire.

Does that sound like a likely culprit? Breadboards have always been fine here for low Mhz kit prior to getting them onto PCBs, and this is the first time I've really pushed passed about 5Mhz in a design. The SD card has to be as close as directly possible to the dsPIC to maintain reliability at high Mhz?

no, thank you.

Reply to
Alison

Hi Rickman,

As per this diagram here;

formatting link

This is further information on the interfacing;

formatting link

I'm not trying to boost the voltages up. It works fine upto about 7Mhz. I'm wondering if it would be *better* to use a specific IC 3.3v/5v bus transceiver when running at upto 25Mhz.

If I don't buffer the 3.3v to 5v line then the errors increase. All of the Microchip documents and examples on the net 3.3v to 5v lines are connected directly.

The ViH is 0.8v.

It is indeed a 5v device.

I see that the dsPIC30 will work up to 5 volts. Why not use a

The 3.3v parts won't run upto 30/40MIPS which defeats the object of a dsp. It is interfacing to a 68000 DMA processor bus with rise times of about 15nS so I have to have the MIPS. That is a 5v TTL bus. So given that there's 30 data lines there, and only 4 on the SD card, it's clear which one gets converted. That side of the bridge has been completed and is working.

Reply to
Alison

Level shifters may do the trick

formatting link

formatting link

formatting link

formatting link

Reply to
Joe G (Home)

SN74LVC04A @ 3.3Vcc Use two inverters in series as a 5V tolerant follower

SN74LVC3G34 @ 3.3Vcc - three followers.

@ 25MHz - I doubt it.

See above. They are available from Digikey.

Use an appropriate logic ICs for voltage translation.

Then use the ICs I mentioned above. They will work up to 30+MHz and easily available from catalog suppliers like Digikey and Mouser.

--
WBR, Yuriy.
"Resistance is futile"
Reply to
Yuriy K.

Ok, so you are dropping the 5 volt outputs from the PIC (not dsPIC from your diagram) to the SD card and running directly from the SD card to the PIC. In general, that should be ok. You will not see any problems from this approach if you voltage levels are ok, which I can't verify since there seems to be some confusion about which PIC you are using. Can you give an exact part number?

he

Typically, the input high voltage threshold is held to 2.4 volts which allows the parts to work with TTL and 3.3 volt CMOS. But in reality the parts are CMOS and the FETs have to be made assymetrical to do this. Often the inputs are left as CMOS inputs which are not compatible with TTL outputs. What is the static voltage on the DATA OUT from the SD card?

Since I don't know which PIC you are using, I don't know what the ViH is, but I can assure you it is *NOT* 0.8 volts. That would be a realistic ViL perhaps.

But which device? The data sheet on the dsPIC33F shows a 40 MIP rating at 3.3 volts.

TABLE 26-1: OPERATING MIPS VS. VOLTAGE Max MIPS dsPIC33F DC5 3.0-3.6V -40=B0C to +85=B0C 40

Perhaps all you need to do is switch PIC devices?

5nS
30

Ok, that is clear. But I don't think the issue is dropping the 5 volt signals to 3.3 volts. The resistors will do that just fine. I suggest that you focus on the voltage level of the signal from the 3.3 volt side to the 5 volt side. You will likely need a buffer here to provide the 4 volts required to drive a 5 volt CMOS input.

Reply to
rickman

Inline

The limits of analysers is that they don't detect actual voltage levels, of course, beyond what they have been set up for as a switching threshold.

0.8V would be ViL (max), not ViH(min).

Which indicates ringing on the line without the resistor.

10cm on breadboard might be ok if the wires are routed appropriately. As I note above, you seem to have ringing on the line. Try a 22 ohm series resistor - that's what I have apart from the 4k7 (mostly) pullups. A 10 - 22pF loading cap might help too, although you should not need it on a properly laid out PCB.

Once on a circuit board, 10cm is not a long way at 25MHz, but you should probably set the line impedance controlled and terminate at each end. Without looking at the datasheets I can't give any direct assistance (and as I have to make dinner shortly I don't have the time ;)

Cheers

PeteS

Reply to
PeteS

[...]

Interfacing fast logic signals trough the voltage dividers is a bad idea. You can get with the solutions like that at 100kHz, but not at

25MHz. Interfacing to a removable card in that way is even worse idea.

Using a buffer IC is the way to go. Consider 74HCT or 74LV series.

Then you shoud definitely use the buffers.

Vladimir Vassilevsky

DSP and Mixed Signal Design Consultant

formatting link

Reply to
Vladimir Vassilevsky

Nods. I need to pickup the scope. Normally I wouldn't be doing electronics, my understanding is basic. I'm the developer :-) The electronics engineer is going through a mid-life-crisis and doesn't want to do electronics as it's not making him happy :-)

This is where the that 0.8v ViH figure came from;

formatting link

That's a page from the dsPIC4013 manual. 70138D.pdf

That answers that then. That sounds good.

I'll look into that. I'm making a piggy back board to go straight under the chip at the moment, so that the card is connected with solid copper.

I'm preparing myself to go for a buffer.

It'll go onto it's prototype pcb once I've cleared up some of this.

Hope you enjoyed it. We made turkey vegetable things on scewers. ;)

Reply to
Alison

Thanks Joe, will read up shortly. :-)

Reply to
Alison

Hi Vladimir,

Would it be ok to suggest the most suitable ones from this list?

formatting link

I have an account there and they're local so I can pickup on Monday a.m.

Thanks :)

Alison

Reply to
Alison

You might be better off finding someone else who is qualified. Although this does not sound like a complex design, even simple logic level interfacing is not hard to do wrong.

Yes, notice that the table says 0.8 Vdd, not 0.8 volts. That means the input thresholds are relative to the magnatude of the Vdd supply. In your case it would be 4.0 volts. No 3.3 volt logic will supply this high an output signal. If you want to meet the spec, you will need a dual supply level shifter on the DATA OUT signal from the SD Card. Or you can just use a transistor. A simple NPN transistor with two resistors will do the job as well if not better than a buffer. If you can't handle the inversion in software, you will need two transistors and three resistors.

"Indicates" and "is" are two different things. Diagnose ringing with a scope. I seriously doubt that you have enough ringing to cause a problem. Even if you had some ringing on the DATA OUT line, unless it were very severe, it would only delay the settling time. At the rates you are working at it is not likely that this truely is the cause of your problem. I suspect it is more likely that the ViH vs. VoH are what is hurting you. But the scope and/or volt meter will tell you better. When the output rises, the initial slope is fairly rapid, but it slows as it approaches Vdd. So if the clock is slow enough the VoH has risen to the full Vdd. With a faster clock the data is sampled on the still rising edge and may not have made it to the actual threshold voltage of the PIC input.

Make sure it is powered by 5 volts and the output rises fully to Vdd. Also make sure the input is compatible with 3.3 volt logic. I am pretty confident you can live a rich full life on this signal without a series resistor once you get the voltage levels correct.

Reply to
rickman

That's not an option. My main job is as an adult escort and I've recently come back from Dubai for £3k. Nose through my /pub directory. There is no one else. No ones going to work on a project for 20y.o. Atari computers. This is out of enjoyment to achieve something other than wandering around shops buying underwear all day. ;-) I have a Computer Science degree which is useless, I did it because I enjoyed working with computers and simplicity, not jumping through corporate hoops for Directors who can just about type with one finger.

This is just enjoyment and achievement for me to do something more.

I have no control over the interface. It's a hardware implemented SPI port. The closest I come is to the transmit and receive registers.

SUCCESS!!

CPU Powered Up. [ DONE ] Powering Down SD Card. [ DONE ] Powering Up SD Card. [ DONE ] Resetting SD Card. [ DONE ] Sending CMD0x00. [ DONE ] Expecting 0x01 Response Token from CMD0. [ PASS ] Sending CMD0x01. [ DONE ] Expecting Valid Response Token from CMD1. [ WAIT ] Sending CMD0x01. [ DONE ] Expecting Valid Response Token from CMD1. [ PASS ] Sending CMD0x09. [ DONE ] 00 26 00 32 1F 59 83 B7 E3 91 CF FF 92 40 40 11 9E AC FF Storage Capacity Calculated in Megabytes. [ 0491 ] Sending CMD0x09. [ DONE ] 00 26 00 32 1F 59 83 B7 E3 91 CF FF 92 40 40 11 9E AC FF Increasing CLK Rate to 7.5Mhz. [ DONE ] Sending CMD0x09. [ DONE ] 00 26 00 32 1F 59 83 B7 E3 91 CF FF 92 40 40 11 9E AC FF Increasing CLK Rate to 15Mhz. [ DONE ] Sending CMD0x09. [ DONE ] 00 26 00 32 1F 59 83 B7 E3 91 CF FF 92 40 40 11 9E AC FF

You're not going to like how I did it though......

The voltage dividers I've replaced with 5k 18-turn pots. They're set to kick out about 4.2v at the moment having checked on the meter, that's the CHIP SELECT, DATA IN, and, CLOCK lines. The 100ohm resister has been removed from the DATA OUT line.

It's running reliably at 15Mhz. I just kept on adjusting the pots until the data became stable. The input lines are about 4v. Mmmmmm. Maybe... The DATA OUT is being driven higher now... The DO is being driven higher, about

4.2v

What does that tell you about the signals?

I have lots of transistors here, bags of different sorts from a workshop clearance a few years ago BC547C ??

Thanks,

Alison

Reply to
Alison

Hi Rickman... ;-)

Could you elaborate on this? I can do this now but I'm not sure what goes where in terms of; R1 R2 R3 T1 T2

Roughly what values? and where do things go, BCE?

I'm fully stocked on resistors, and have quite alot of different PNPs and NPNs.

Alison

Reply to
Alison

Interesting. I checked out every file including the logs. I can't say I feel your pain, but I get the idea.

If it's a paying job they will!

ch

Tell me about it. I am at a point where I could retire if I wanted to. I have found that jobs provide little satisfaction and I am about fed up with it. Too bad I'm too old to do what you do!

Well, you may not like what I am going to tell you.

rt.

That is the point of interface where you can invert the data if you want. But it is 6 of one and half dozen of the other. You can get a dual buffer in a package as small as a transitor if I can remember which one we use a lot. It is tolerant of up to +-7 volts on the input, but what you need is for it to be 5 volt powered and I don't recall if it is.

Here is a dual N-FET which does not need the input resistor. EM6K1 is in stock at digikey. Or if that package is too small for you to solder, the FDC6305N is a bit larger and should work too. Just connect one FET input to the DATA OUT signal (a light pulldown will keep it from floating when the SD card is not inserted) with a pullup resistor to 5 volts. Connect the other FET to the first drain in the same manner with the second drain to the PIC input. This will give you a clean 5 volt transistion and your problems should be solved.

the

out

No, I don't like how you did it. And you won't like why it works. By driving the SD card inputs to 4.2 volts you are forward biasing the protection diodes in the SD card. This pulls the Vdd on the card up higher so that the output voltage is higher. This is *very* bad. Don't expect your card to live a rich full life if you continue to do this.

Much better would be to use a buffer on the DO output or to use the transistors. The BC547C should work just fine. The package is a bit large, but I guess that is not an issue. Connect two of them in the same manner as above, but with a 1 Kohm resistor in series with the base of the first. Use 1 Kohms for the two pullups and you can ignore the series resistor on the second.

It is hard to describe well, so I made a drawing.

formatting link

Reply to
rickman

The drawing from my other post did not inititially include the BCE markings, so I added them. You can check the data sheet for the part to see where each function is on the package. This will be very non-critical in terms of transistor selected or resistor value. Just make sure you use an NPN or N-channel device.

Reply to
rickman

Hi Rickman,

thanks :-)

I've since tried a 7407 out of my junk box which I've found out why it was in there, it's a dud.

A level shifter is another option? I've seen mention of a zener and two resisters, yet have as yet to get past companies wanting to sell me examples and datasheets..

The 4.2v has been dropped back down to 3.3v but in my mind it makes me believe that the SD DATA OUT was the problem, in that the dsPIC wasn't registering a '1'. I was getting impatient, and had enough cards to risk blowing one or two.

It will reliably register a '1' at low Mhz

Reply to
Alison

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.