Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Published circuit not correct?!

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> KokkeKat FAT-free SD card lib
View previous topic :: View next topic  
Author Message
Walter

Bascom Member



Joined: 14 Nov 2007
Posts: 18

germany.gif
PostPosted: Sat Oct 01, 2011 3:03 pm    Post subject: Published circuit not correct?! Reply with quote

I want to use the KokkeKat library. But at the beginning i wonder at the published curcuit.
The Mega32 require 5V. I suppose the SD-Card will be damaged cause the direct connections. There is probably the little mistake, that it has to be the Mega32L with 3,3V.
Many application require an Megaxx with 5V, so it would be nice to publish a circuit with a level shifter for example the 74HC4050.
My final question: which pull ups are required when I use the 74HC4050 for MOSI, SCK and CS. Is it enough to use one pull up for the direct connected MISO? And is the level enough for a direct coupling of MISO or is an aditional level shifter recommended? Is the posted circuit ok?

Thank you for an answer
Walter
Back to top
View user's profile
KokkeKat

Bascom Member



Joined: 08 May 2011
Posts: 59
Location: Stockholm

sweden.gif
PostPosted: Sun Oct 02, 2011 7:12 pm    Post subject: Reply with quote

Hi Walter

You are right. The 5V ATMega32 needs a level shifter to 2.7-3.6V. The circuit drawing I published should say ATMega32L. Thanks for pointing this out.

The circuit I published is correct for microcontrollers operating at 2.7-3.6V. (It's copied from the SD datasheet.)

To use a level shifter, just insert it between the microcontroller and the rest of the circuit. I don't know if the SD card output (MISO) always exceeds the minimum "high" level for the AVR you are using. The ATMega32 is specified at 0.6*Vcc, which is 3V at a 5V rail. You might have to use two 74HC4050 or one 74HC4050 and "two transistors plus three resistors".

You should use all pull-up resistors, with the values specified in the SD datasheet.

You could also look for proto boards that have an on-board level shifter.

Kind regards

Niclas
Back to top
View user's profile
Walter

Bascom Member



Joined: 14 Nov 2007
Posts: 18

germany.gif
PostPosted: Mon Oct 03, 2011 6:02 pm    Post subject: Reply with quote

Hi Niclas,
thank you for the reply. I have added the pull-ups. The level shifter provide a fixed potential at the SD-Inputs, so the pull-ups has to be at the input of the level shifter.
What I have learned meanwhile: a problem is the floating of the Mega-Pins especially during ISP-programming. So it is very importend to have a high-level at CS with an inserted SD-Card. Somewhere I found (but I can't find it again) that the DO-Pin of the SD-Card is floating until it is ready for the answer, that is during waiting for the response. So also the pull-up at DO is important. Floating Input-Pins are never good, so the other pull-ups are recommended.

The direct connection of the MISO and DO is ok with the >=3V for the Mega-Input and the >=3,2V of the 74HC4050 in worst case. But when the VCC of the Mega is a little bit higher or the VCC of the 74HC4050 a little bit lower, a aditional level shifter is required. In this case the MAX3392E is ideal with its 3*5V->3,3V and 1*3,3V->5V translators.

I hope I don't bother you with this hardware problems, but the Web is full of problems with this theme and with total different solutions.
Corrections of my posting are welcome.

Have a nice day
Walter
Back to top
View user's profile
KokkeKat

Bascom Member



Joined: 08 May 2011
Posts: 59
Location: Stockholm

sweden.gif
PostPosted: Mon Oct 03, 2011 9:04 pm    Post subject: Reply with quote

Hi Walter

Thanks for the information about MAX3392E. I looked it up at www.farnell.se and it's about 6 EURO apiece. It's just what we need, but a bit expensive. Could you please report if you find a similar but cheaper IC?

You are right about the placement of the pull-ups. They must be at the output of the sending "terminal".
In other words: The CS and MOSI pull-ups must be between the AVR and the level shifter. The MISO pull-up must be between the SD card and the level shifter.

I tried to find information about three-state DO and here's what I found:
http://alumni.cs.ucr.edu/~amitra/sdcard/Additional/sdcard_appnote_foust.pdf

"The SD 1-bit protocol is a synchronous serial protocol with one data line, used for bulk data transfers, one
clock line for synchronization, and one command line, used for sending command frames. The SD 1-bit protocol
explicitly supports bus sharing. A simple single-master arbitration scheme allows multiple SD cards to share a
single clock and DAT0 line."

Please note the difference between the SD 1-bit, SD 4-bit and SPI modes. However, the basic principles should apply to all.

I found similar information here:
http://www.sandisk.com/Assets/File/OEM/Manuals/SD_SDIO_specsv1.pdf

"It is recommended that multi-slot hosts intending to support SDIO (SDIO aware) provide a separate CLK to
each slot, to allow the I/O devices to be placed in a low power state on a slot-by-slot basis. After reset, all data
lines (DAT[3:0]) shall be in the hi-Z state on both the host and card(s) to avoid bus conflict."

Again, note the difference between SD and SDIO, but the basic principles should apply.

Here it says that the pull-ups should be between 10k and 100k. You must have pull-ups on DAT0-DAT3 plus CMD/DI (MOSI).
http://www.flashgenie.net/img/productmanualsdcardv2.2final.pdf
It also specifies "output high voltage" as 0.75*Vdd, which at 3.3V is 2.475V.
This means that you should have a level shifter also on the MISO.

For completeness' sake, here's the main SD specification:
https://www.sdcard.org/downloads/pls/simplified_specs/Part_1_Physical_Layer_Simplified_Specification_Ver_3.01_Final_100518.pdf

Kind regards

Niclas
Back to top
View user's profile
KokkeKat

Bascom Member



Joined: 08 May 2011
Posts: 59
Location: Stockholm

sweden.gif
PostPosted: Mon Oct 03, 2011 9:27 pm    Post subject: Reply with quote

Hello again

Just to avoid confusion about multi-card topologies:

See section 3.3 in this document:
http://www.flashgenie.net/img/productmanualsdcardv2.2final.pdf

Here it says that SPI mode can share MOSI, MISO, and SCK, while the !CS must be unique for each SD card. (Regular SPI sharing.)

I might be mistaken, but it could be that the SCK in some cases should be unique for each SD card, in case you want any single card to be able to enter power-down mode. This is because the SD card depends on an external clock for its internal functionality. For example, each transfer must be trailed by 8 dummy clock cycles in order for the SD card to complete its processing. Perhaps this external clock signal could prevent the card from entering power-down even though the !CS signal is not addressing this particular card. However, I don't know what is the actual case here.

Kind regards

Niclas
Back to top
View user's profile
Walter

Bascom Member



Joined: 14 Nov 2007
Posts: 18

germany.gif
PostPosted: Mon Oct 03, 2011 11:14 pm    Post subject: Reply with quote

Hi Niclas,
thank you for the information. It becomes clearer. There is no wonder about the problems all around. I have never seen a pull-up in circuits with a level shifter.
Forget my posting about the "ok" for direct coupling of the MISO - in that direction there was no 74HC4050. Perhaps the pull-up can save some mV.

For the MAX3392E I found this shop (2,69):
http://de.mouser.com/Search/Refine.aspx?Keyword=MAX3392E

Good night
Walter
Back to top
View user's profile
Frankeman

Bascom Member



Joined: 11 Aug 2004
Posts: 945
Location: the Netherlands

netherlands.gif
PostPosted: Mon Oct 03, 2011 11:19 pm    Post subject: Reply with quote

hi,

Find a voltage-level translation device with this tool at TI:
http://focus.ti.com/logic/docs/translationselection.tsp?sectionId=458

A 4 lines level translator costs less than 2.00
Back to top
View user's profile
Walter

Bascom Member



Joined: 14 Nov 2007
Posts: 18

germany.gif
PostPosted: Wed Oct 05, 2011 12:11 pm    Post subject: Reply with quote

Hi,
now I found an even better level shifter in Frankeman's link. It's the TXB0104:
http://www.ti.com/lit/ds/symlink/txb0104.pdf
It is designed especially for SD-Cards and SPI - they say in:
http://www.ti.com/lit/an/scea043/scea043.pdf
It's chaeper, needs no pull-ups and has seperate High-Vcc and Low-Vcc.
The speciality: there is no difference between In- and Output so it works in both directions. It has a week driver over a 4K-Resistor which is over-driven by the external driver. And it has a sort of memory like a flip-flop - when the driver goes in tri-state it remains in its old state.
It seems to be very good and I've found it by Farnell and Mouser for 2 single-price.

I not realy know if there are situations in software where the "memory" don't remember at that state the pull-up would do.

By the way: the cheepest level shifter is the 74LS07 with open collector. It can drive every voltage and an input of >=2V is sufficient. The only problem is the frequency cause the pull-up has to drive the load. So it will work only with low pull-ups and low frequency.

Have a fine day
Hermann
Back to top
View user's profile
KokkeKat

Bascom Member



Joined: 08 May 2011
Posts: 59
Location: Stockholm

sweden.gif
PostPosted: Wed Oct 05, 2011 9:32 pm    Post subject: Reply with quote

Thanks for the info!
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> KokkeKat FAT-free SD card lib All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum