SD cards and pullups

ThricThric Posts: 109
edited August 2012 in Propeller 1 Vote Up0Vote Down
So i've been looking into SD cards and I've seen most objects say that pullups are needed on 6 of the pins. However, I've read on the forums that these pullups aren't really needed and the objects work any ways. I was wondering which idea is true, and if pullups are not required what do I do to the non connected pins (the 4 not connected to the propeller)? Can they be allowed to float?

I'm asking this because I've tried two different setups and it seems like the pullups are required, yet some say the are not and I'm not sure why.
Thanks

Comments

  • 25 Comments sorted by Date Added Votes
  • JonnyMacJonnyMac Posts: 5,853
    edited January 2012 Vote Up0Vote Down
    Resistors are cheap, so add them. I don't know if the DO pin from the SD card is driven or open-collector/open-drain; if the latter, you need the pull-up; if the former, the pull-up will not hurt.
    Jon McPhalen
    Hollywood, CA
    It's Jon or JonnyMac -- please do not call me Jonny.
  • MagIO2MagIO2 Posts: 2,181
    edited January 2012 Vote Up0Vote Down
    SD cards can be used in a bus setup, which means that several Cards can use the same DO/DI/CLK lines. In those setups you want to avoid that the devices can damage each other. That's why something like the open collector (oc) output has been invented. A normal output really drives a low as well as a high signal. Drive means that it really connects power supply/ground to the signal line via transistor/FET. This means in case of an error you can have the line driven low by one device and driven high by another device which is called a shortcut.

    With oc pins you don't have this problem. These are only driven low by the devices and defaulted to high by the pull-up.

    For the propeller you could do some changes to make the SD driver work without pullups for DI/CLK by setting the pins high instead of switching to input-mode. But are you really in the need of saving this huge amount of money? ;o)
  • ThricThric Posts: 109
    edited January 2012 Vote Up0Vote Down
    Well it seems that I'm making some progress on why it doesn't work, It turns out I had a bad solder joint which is why my program kept returning -1 when ever I tried to start up the SD card. Now however it is returning -100 >.< . Could anyone shine some light why I'm returned this value?

    I'm using FSRW 2.6 and when I try to run mount.explicit_mount(...) it returns -100 when a SD card is present and -1 when it isn't.

    I'm trying to avoid adding resistors because of space for now, just making sure I test everything before committing to adding the pullups.

    Thanks
  • ThricThric Posts: 109
    edited January 2012 Vote Up0Vote Down
    It works!! :D

    Seems like the pullups aren't required :) and i just had to run through the solder joints again! Those micro SD card socket joints are hard to reach :P.
    Thanks for all the help and suggestions!
  • Tracy AllenTracy Allen Posts: 6,103
    edited January 2012 Vote Up0Vote Down
    One reason for pullups is to assure that pins on the propeller will not float when a card is not present. From the perspective of the SD card, the specifications I have seen do recommend pullups on the pins that are not used in SPI mode, and it is good practice to include them on all the signal pins. In operation, the pins default to a high state when the card is not active, so pullups allow the lowest quiescent current.
  • Cluso99Cluso99 Posts: 12,961
    edited January 2012 Vote Up0Vote Down
    There are a few reasons...
    1. Pullups reduce power usage when the pins float. But not much.
    2. A pullup should be on the /CS pin to ensure the SD card remains inactive (and this will reduce power consumption on other pins too)
    3. Since the prop will drive DI, CLK and effectively /CS, they do not really require pullups (see 2. above because before the [prop runs its code /CS will be tristate so the pullup should be there, but does work without if you keep the pin driven)
    3. IIRC a pullup should be on DO since this can be tristate out from the card. However, I also read that the cards have their own internal pullups now anyway - quite high but there.

    Until recently,I have always put 10K pullups on the 4 pins DI, DO, CLK, /CS and left the other 2 floating. I can confirm that pullups on /CS and DO only also works and I have read others have only used a pullup on /CS. Obviously the other 2 pins are 3v3 and gnd and dont require pullups.
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Tracy AllenTracy Allen Posts: 6,103
    edited January 2012 Vote Up0Vote Down
    Interestingly enough, the specification mentions only one internal pullup resistor, and that is on pin 1, chip select. Here from the spec:
    Screen shot 2012-01-22 at 12.04.17 AM.jpg

    Ah! card detection, possibly also to keep the card deselected at insertion. And it can be turned off/on by a software command. Some documents emphasize that the resistor is on by default. It is too bad all this information is such a closely guarded secret. If you want to use it for card detection, you'd have to leave off your own pullup resistor, and maybe use a very weak pulldown instead. Has anyone tried that?

    The SD physical layer specification does not have much to say about pullup resistors, except that they should be used to prevent excessive current from floating inputs. That applies especially to pins 8 and 9 on the card (the ones on opposite ends), which are not used in SPI mode on the Propeller.

    This got me thinking about my assumption that the default state of the pins is high, so I hooked it up to the 'scope. I was mistaken. So long as the card is mounted, the DO, DI and SCK pins stay low during periods of card inactivity. Only CS is is high during those periods, and then goes low when the card is being accessed. When the card is un-mounted, released, the DO is tri-stated and can be pulled high by the external resistor. But it looks like SCK and DI driven from the Propeller stay at the low level (FSRW). This matters in super-low power systems, because you don't want current wasted in pullup/down resistors. In those systems you want to turn the card power off completely, but sometimes that is not possible. So that is a reason to leave pullups off of DI and SCK.
  • Tracy AllenTracy Allen Posts: 6,103
    edited January 2012 Vote Up0Vote Down
    I tested several cards to measure whether a pull-up is present or not in the card itself. Yes, all of the cards I tested did in fact have an internal pullup present on the chip select (CS) line, but not on the others (DI, SCK or DO).

    Here are the measured values of the pull-ups on CS:
    Sandisk 4GB HDSC 70kΩ
    Transcend 2GB SD 20kΩ
    Transcend 2GB µSD 45kΩ
    PNY 4GB SDHC 20kΩ
    Panasonic 16MB SD 45kΩ (yes, MB not GB--an really old card)
    A small sample, but none lacked it. It is weak but would normally suffice to keep the card deselected, and it could (as the SD spec suggests) be used as part of a card present detection scheme.

    On the other lines of those SD cards, there were no pullups, at least none heavier than the order of of 10+ MΩ of leakage current.

    -- DO output line from the chip is tri-stated when chip select is high, as it must be for it to play nice on an SPI bus with other slaves. It will float if it does not have an external pullup and no other source drives it.

    -- DI and SCK inputs to the SD are are controlled by the master, in our case the propeller. Under FSRW those lines are also tri-stated to high impedance when the SD card is deselected. A programmer might choose to leave those prop pins either high or low instead of input in order to avoid having to install an external resistor.

    I think the answer to the OP is that the cards can be expected to work well without pullups, but anyone designing a commercial product should put them in.
  • RaymanRayman Posts: 8,317
    edited January 2012 Vote Up0Vote Down
    I also don't think you need pull-up resistors anymore.
    I think some of the very old cards needed them, but any within the last couple years should be fine.

    Instead of pull-ups, you can use the four 10k resistors for card detection without using any more pins...
    Check out my PSM schematic to see how...
    Prop Info and Apps: http://www.rayslogic.com/
  • Peter JakackiPeter Jakacki Posts: 6,613
    edited January 2012 Vote Up0Vote Down
    Yes, I have mentioned many times in these SD card threads about the internal pullup on CS and how that can be used for card detect rather than a dedicated switch but this feature seems to be ignored by the masses for some reason but you only have to read the specs. I just pulse the CS low then return it to an input and if it stays low (within a few microseconds or so) then there is no card present, otherwise the CS will be sensed high. I have designs with pull-ups on the unused lines and ones without and I have never had a problem even for those ones which are used in large volume. However, it is very easy to add pull-ups and they don't take up any room at all especially if you are using surface-mount resistor networks. So it's interesting that CS is seen as the pin to definitely use the pull-up on and yet it is the one pin where it is better to leave it off!
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    Tachyon Forth News Blog
    TACHYON DEMONSTRATOR
    Brisbane, Australia
  • RaymanRayman Posts: 8,317
    edited January 2012 Vote Up0Vote Down
    I think I like this CS card detection scheme... This is the first I've heard of it...

    If the pull-up is turned off with software, does it come back again when power is cycled?
    Prop Info and Apps: http://www.rayslogic.com/
  • Tracy AllenTracy Allen Posts: 6,103
    edited January 2012 Vote Up0Vote Down
    Sorry I missed your comments about that in other threads Peter and sniffed it out myself at SDcard.org. Oh well, always rediscovering. This particular factoid does indeed seem to be little appreciated.

    The spec, the current "simplified" version 3.01 does not state emphatically that the pullup on CS\ shall be turned on by default. Thus I wanted to test a few. I have a copy of the full (not "simplified") earlier version 1.0 of the spec, and it does not say either. Peter, have you ever run across one that did not have the pullup enabled?

    I don't know the answer to the question about whether it would come back on automatically after being turned off, but my guess is that it is a non-volatile eeprom setting. I don't know why one would want to turn it off. I is certainly a nice option for card detection and would avoid having to implement a separate pin to the CD switch.

    On the down side, the pullup is weak. Suppose the next pin over is running PWM at the same time that a card access is happening. Coupling could induce an error, but I don't think I have ever had a problem with that using 10k pullups.
  • Cluso99Cluso99 Posts: 12,961
    edited January 2012 Vote Up0Vote Down
    I use the /CS for other purposes when high (prop power up default is t/s so my pullup enables other things. I also share the other pins, hence the requirement to force the card to release the DO pin by issuing some additional clocks.

    As for card detection, see Kye's driver. It uses 2 series 10K pullups. The junction goes to the card detect switch to ground. So it changes the pin from pulled up to pulled down. Not sure whick pin this is on. He does the same for write protect, but this is not available on microSD cards - too small.
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Peter JakackiPeter Jakacki Posts: 6,613
    edited January 2012 Vote Up0Vote Down
    Yes, the pull-up does come back on after a power cycle but I never issue a command to turn off the pull-up nor is there a need to do so. It does not matter that the pull-up is perceived as "weak" as there is no real capacitance or loading on this line and the CS pin is always asserted from the Prop unless it's doing a CD check. It would also seem improbably that any real cross coupling would occur at anything but at a very high frequency and that would still need the tracks to be run for quite a distance (several inches) in parallel and close proximity which seems highly improbably once again and would be poor design as well.
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    Tachyon Forth News Blog
    TACHYON DEMONSTRATOR
    Brisbane, Australia
  • RaymanRayman Posts: 8,317
    edited January 2012 Vote Up0Vote Down
    Ok, sounds like CS is a real winner for card detect. Perfect for uSD cards.

    Full size SD cards still have the manual WP slider though. I think my 2-resistor scheme is still a good way to detect that without using extra pins...
    Prop Info and Apps: http://www.rayslogic.com/
  • Tracy AllenTracy Allen Posts: 6,103
    edited January 2012 Vote Up0Vote Down
    Using CS\ that way to detect the presence of the card is already saving a prop pin and solving a wiring layout problem. I cut the trace to the external pullup on CS\ and repurposed the prop pin that had been dedicated to the CD (chip detect) pin. I totally agree with Peter about the noise pickup after thinking about it a bit more. When active all the pins are driven, so only with a poor layout would inter-pin coupling ever be a problem.
  • SapiehaSapieha Posts: 2,964
    edited January 2012 Vote Up0Vote Down
    Hi Thiric and Tracy.

    It is NOT so simple.
    Some cards need all resistors some NOT.

    BUT For not confusing SD in commands mode it is better to have all 6 installed --->
    That for Not confusing SD if You work in SPI else 4-Bit's mode.

    On my end I work on 4-Bit's mode driver that why I know what it need's


    Interestingly enough, the specification mentions only one internal pullup resistor, and that is on pin 1, chip select. Here from the spec:
    Screen shot 2012-01-22 at 12.04.17 AM.jpg

    Ah! card detection, possibly also to keep the card deselected at insertion. And it can be turned off/on by a software command. Some documents emphasize that the resistor is on by default. It is too bad all this information is such a closely guarded secret. If you want to use it for card detection, you'd have to leave off your own pullup resistor, and maybe use a very weak pulldown instead. Has anyone tried that?

    The SD physical layer specification does not have much to say about pullup resistors, except that they should be used to prevent excessive current from floating inputs. That applies especially to pins 8 and 9 on the card (the ones on opposite ends), which are not used in SPI mode on the Propeller.

    This got me thinking about my assumption that the default state of the pins is high, so I hooked it up to the 'scope. I was mistaken. So long as the card is mounted, the DO, DI and SCK pins stay low during periods of card inactivity. Only CS is is high during those periods, and then goes low when the card is being accessed. When the card is un-mounted, released, the DO is tri-stated and can be pulled high by the external resistor. But it looks like SCK and DI driven from the Propeller stay at the low level (FSRW). This matters in super-low power systems, because you don't want current wasted in pullup/down resistors. In those systems you want to turn the card power off completely, but sometimes that is not possible. So that is a reason to leave pullups off of DI and SCK.
    Regards
    Sapieha
    _____________________________________________________
    Nothing is impossible, there are only different degrees of difficulty.
    For every stupid question there is at least one intelligent answer.
    Don't guess - ask instead.
    If you don't ask you won't know.
    If your gonna construct something, make it as simple as possible yet as versatile/usable as possible.
  • Cluso99Cluso99 Posts: 12,961
    edited January 2012 Vote Up0Vote Down
    Sapieha: Very interested in your 4bit mode. Is it subject to licence or has it been reverse engineered in cleanroom???

    BTW Happy New Year - havent seen you on msn lately (mainly because I have not been on much).
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • SapiehaSapieha Posts: 2,964
    edited January 2012 Vote Up0Vote Down
    Hi Cluso.

    I don't need reverse engineering as I have original data sheet to 4-Bit's mode with all needed info to build driver's.
    BUT I'm not sure of license if it is free.

    Ps. My MSN is always ON so write to it -- If I'm with computer I answer directly else answer as fast I'm coming home.

    Cluso99 wrote: »
    Sapieha: Very interested in your 4bit mode. Is it subject to licence or has it been reverse engineered in cleanroom???

    BTW Happy New Year - havent seen you on msn lately (mainly because I have not been on much).
    Regards
    Sapieha
    _____________________________________________________
    Nothing is impossible, there are only different degrees of difficulty.
    For every stupid question there is at least one intelligent answer.
    Don't guess - ask instead.
    If you don't ask you won't know.
    If your gonna construct something, make it as simple as possible yet as versatile/usable as possible.
  • Cluso99Cluso99 Posts: 12,961
    edited January 2012 Vote Up0Vote Down
    Sapieha: If you got the info from the data sheet then it is proprietry as I understand. The SD card organisation require large $ annually and $ per product using the spec, at either end (i.e the card or the socket). That is why 4bit mode is not used in the hobby arena. The SPI mode does not carry this impost.
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • RaymanRayman Posts: 8,317
    edited January 2012 Vote Up0Vote Down
    Sapieha, can you provide an example of an SD card that requires pullups?

    I've tested a lot of them and haven't found one yet...
    If I knew there were some newer SD cards around that needed pullups, I'd change my current plans to leave them off...
    Prop Info and Apps: http://www.rayslogic.com/
  • Cluso99Cluso99 Posts: 12,961
    edited January 2012 Vote Up0Vote Down
    I think it fairly safe to presume high value pullups on all the newer cards. Everything these days is trying to reduce current and this is one way to ensure low current. These cards are used in phones and cameras by the bucketloads and they demand low current. But just to be safe, put a pullup on the -CS line to ensure the card cannot be selected inadvertantly. If you want to check for card insertion, another 2 series pullups (Rayman or Kye method) on DI. Just my 2c
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Peter JakackiPeter Jakacki Posts: 6,613
    edited January 2012 Vote Up0Vote Down
    Cluso99 wrote: »
    I think it fairly safe to presume high value pullups on all the newer cards. Everything these days is trying to reduce current and this is one way to ensure low current. These cards are used in phones and cameras by the bucketloads and they demand low current. But just to be safe, put a pullup on the -CS line to ensure the card cannot be selected inadvertantly. If you want to check for card insertion, another 2 series pullups (Rayman or Kye method) on DI. Just my 2c

    The pull-up on the CS line is built-in to the card and guaranteed to be connected, so why add one externally when this gives you no advantage and only means that you can no longer use the CD detect from CS method? The card cannot be "inadvertently" activated even if you were to pull the CS low as you still need to issue a command sequence anyway.
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    Tachyon Forth News Blog
    TACHYON DEMONSTRATOR
    Brisbane, Australia
  • jcullins0jcullins0 Posts: 10
    edited August 2012 Vote Up0Vote Down
    For whom ever is interested I found a hinged micro SD card socket by Molex and from Mouser electronics. 538-47219-2001
    It makes it soooo much easier to sloder, just slide the plastic part fwd and it hinges up for easy access to the pins.
    The solder points on the metal shell were a little off on one of them but does make life easier.
    I am sure a lot of you have already found it.
Sign In or Register to comment.