• AVR Freaks

SD CARD intermittent failures

Author
mhark
Starting Member
  • Total Posts : 47
  • Reward points : 0
  • Joined: 2008/12/09 09:34:26
  • Location: 0
  • Status: offline
2011/03/29 14:33:21 (permalink)
0

SD CARD intermittent failures

 
Hello All,
 
I have designed a system with PIC32 using a SD Card slot. I followed the circuit diagram provided by the Microchip SD/MMC library, however I did not add the buffer. I am seeing failures to initialize the SD card on boot up. I have 8 seconds after power up, before I try to initialize the SD Card, I am not sure if the buffers are really needed. Please provide me with some inputs

mhark

post edited by mhark - 2011/03/29 14:34:37
#1

15 Replies Related Threads

    Aiden.Morrison
    Super Member
    • Total Posts : 729
    • Reward points : 0
    • Joined: 2005/02/25 11:18:31
    • Location: Canada
    • Status: offline
    Re:SD CARD intermittent failures 2011/03/29 15:02:35 (permalink)
    0
    Could you clarify what you mean by buffers?

    I have two systems that appear to be working just using direct connections between the processor pins and the card.
    #2
    mhark
    Starting Member
    • Total Posts : 47
    • Reward points : 0
    • Joined: 2008/12/09 09:34:26
    • Location: 0
    • Status: offline
    Re:SD CARD intermittent failures 2011/03/29 15:52:17 (permalink)
    0
    Hi Morrison,

    In the schematics provided by Microchip, http://ww1.microchip.com/...eviceDoc/DS-51583b.pdf they added a MC74VHCT125A quad bus buffer for all inputs to and outputs of the SD card connector.

    I think, the buffer is not required, but I am not sure.

    Is it a possibility that it might be due to the fact that I am using SD Card from Netlist(1/2GB)/Wintec(1GB) ?? Maybe I need to switch to Sandisk

    The problem is, on power-up the SD card fails to initialize ( I am guessing it might be the FSInit() function)

    -mhark
    #3
    Aiden.Morrison
    Super Member
    • Total Posts : 729
    • Reward points : 0
    • Joined: 2005/02/25 11:18:31
    • Location: Canada
    • Status: offline
    Re:SD CARD intermittent failures 2011/03/29 15:54:30 (permalink)
    0
    Without knowing more, my first guess is to double check the SPI clock.

    Initialization has to be done at low speeds 

    #4
    mhark
    Starting Member
    • Total Posts : 47
    • Reward points : 0
    • Joined: 2008/12/09 09:34:26
    • Location: 0
    • Status: offline
    Re:SD CARD intermittent failures 2011/03/29 17:17:18 (permalink)
    0
    The SPI clock is running at 400KHz during initialization of the SD card, and changes to 5MHz before sending the Turn off CRC7 command in the initialization code.

    The application later runs at 2.857 MHz.
    #5
    mhark
    Starting Member
    • Total Posts : 47
    • Reward points : 0
    • Joined: 2008/12/09 09:34:26
    • Location: 0
    • Status: offline
    Re:SD CARD intermittent failures 2011/03/30 11:39:49 (permalink)
    0
    Hi Morrison

    Is it necessary to format (FAT32 ) SD CARDS in windows computer before using?? I dont follow this as of now. I am just trying to figure whats going wrong in my design or the library code which fails to initialize at times. Can you also let me know what kind (manufacturer) of SD Cards you use in you application.

    Thanks for the help

    mhark
    #6
    Aiden.Morrison
    Super Member
    • Total Posts : 729
    • Reward points : 0
    • Joined: 2005/02/25 11:18:31
    • Location: Canada
    • Status: offline
    Re:SD CARD intermittent failures 2011/03/30 12:24:36 (permalink)
    0
    Hi there,

    If you're using the MDD library then yes I think you do have to format the cards ahead of time.  Implementations like FAT-FS have the option to format the volume if you request it.

    The mount function in the MDD library only mounts a pre-existing file system, so it's highly likely you have to have the card preformatted.

    I'm using several no name brands, lexars, kingston, and a few corsair.


    If you search my posts you'll see where I posted a FAT-FS implementation for the pic32 using a sparkfun electronics dev board with an SD socket and some LED's soldered on.
    #7
    frostmeister
    Super Member
    • Total Posts : 769
    • Reward points : 0
    • Joined: 2006/12/03 10:20:52
    • Location: UK
    • Status: offline
    Re:SD CARD intermittent failures 2011/03/31 03:40:35 (permalink)
    0
    On a dsPIC33F128GP804, I was able to initialise the card and write sector by sector at 10MHz SPI clk. No buffers, no low speed start up. (Sandisk 2GB using crc7 on commands & crc16 on data)

    Part of my development in the near future will be porting this code to C32, and working with larger cards. The main difference is the addressing, where cards <4GB are addressed 0x00000000, 0x00000200, 0x00000400 etc for each physical sector, cards 4GB and above would use 0x00000000, 0x00000001, 0x00000002 etc for physical sector addresses.

    I don't think I'll be using MDD though, as I want to keep the overheads as low as possible. A couple of longs(C30) or ints(C32) to track present block and store the next free block to write to is pretty hard to beat, lol!

    Most new SD cards - all the ones I've tried - come ready formatted with FAT32 though, so I wouldn't have thought that was a problem.
    #8
    Aiden.Morrison
    Super Member
    • Total Posts : 729
    • Reward points : 0
    • Joined: 2005/02/25 11:18:31
    • Location: Canada
    • Status: offline
    Re:SD CARD intermittent failures 2011/03/31 08:26:00 (permalink)
    0
    Frost - I've posted a simple port of FAT-FS to a pic32 target - with 20 MHz SPI, and code optimization level 1 the write speed can get up to ~740 kB/sec on a good SD card using 4k block writes.
    #9
    mhark
    Starting Member
    • Total Posts : 47
    • Reward points : 0
    • Joined: 2008/12/09 09:34:26
    • Location: 0
    • Status: offline
    Re:SD CARD intermittent failures 2011/04/01 13:11:37 (permalink)
    0
    frostmeister

    Most new SD cards - all the ones I've tried - come ready formatted with FAT32 though, so I wouldn't have thought that was a problem.



    Th SD card from Sandisk 1GB is running as FAT16. I am still not convinced that formatting is the cause of the problem. I am using MDD since it was provided by Microchip and will be compatible with other Microchip libraries.

    #10
    Aiden.Morrison
    Super Member
    • Total Posts : 729
    • Reward points : 0
    • Joined: 2005/02/25 11:18:31
    • Location: Canada
    • Status: offline
    Re:SD CARD intermittent failures 2011/04/01 14:35:43 (permalink)
    0
    Microchip example code like that is usually pretty good as a proof of concept, though some of the inherent features make them a little less usable than they might otherwise be.

    For example, the fact that the same code runs on pic 18's, 24's, 30's, 33's and pic32's is convenient, but also clogs them with #ifdef statements that quadruple the size of the code and make it harder to understand (to my eyes anyway).

    Also, the main goal of the examples is to demonstrate the concept, not to have it work at high performance.  For example the MDD library uses single sector writes on all SD cards - this means that on some SD cards with MDD I get less than 13 kB/second of write performance.

    Those same cards under FAT-FS (which uses multiblock writes) can get over 300 kB/sec.

    Just something to think about - if you need this code to perform quickly later, you might want to adapt a different example.
    #11
    P Lameijn
    Super Member
    • Total Posts : 1967
    • Reward points : 0
    • Joined: 2004/01/22 18:30:23
    • Location: The Netherlands
    • Status: offline
    Re:SD CARD intermittent failures 2011/04/01 14:38:10 (permalink)
    0
    You could first try if you can read/write raw sectors without using FAT.

    Regards,
    Peter
    #12
    mhark
    Starting Member
    • Total Posts : 47
    • Reward points : 0
    • Joined: 2008/12/09 09:34:26
    • Location: 0
    • Status: offline
    Re:SD CARD intermittent failures 2011/04/04 11:15:14 (permalink)
    0
    P Lameijn

    You could first try if you can read/write raw sectors without using FAT.


    Can you give me an example how I can read/write raw sectors please

    -mhark
    #13
    mhark
    Starting Member
    • Total Posts : 47
    • Reward points : 0
    • Joined: 2008/12/09 09:34:26
    • Location: 0
    • Status: offline
    Re:SD CARD intermittent failures 2011/04/13 08:38:46 (permalink)
    0
    We got another failure and I diagnosed that the MDD_MediaDetect() never works. The Card detect signal is high, we can see the card being the SD card holder but the signal seems to be high instead of low.

    I am thinking to comment the detect media code as of now

    -mhark
    #14
    felipevip
    Starting Member
    • Total Posts : 32
    • Reward points : 0
    • Joined: 2010/02/09 08:32:31
    • Location: 0
    • Status: offline
    Re:SD CARD intermittent failures 2011/05/05 09:22:55 (permalink)
    0
    Hi,

    I read in the forum that you were able to achieve over 700KB/s data transfer and I was wondering how you did this.
    From your threads I'm assuming that you're using chan's FAT-FS, is this correct?
    How did you adapt the code to be able to do multi block writes?
    I have managed to do multi block writes to the SD card in RAW mode (no FS) but I'm trying to do this using FS.
    At the moment I'm using microchip's FS but I'm getting stuck with it.
    If you can give any help I would appreciate.

    Regards,

    Felipe
    #15
    RESNIC
    Senior Member
    • Total Posts : 174
    • Reward points : 0
    • Joined: 2005/10/24 15:39:04
    • Location: ITALY
    • Status: offline
    Re:SD CARD intermittent failures 2011/05/10 00:54:11 (permalink)
    0
    Ciao,

    Also I insert on mine board an ***125 between DSPIC33 and SDCard, but I found that that component cannnot supply the right current, so at the end I don't use this components, and I drive directly the SDCard. On mine board there is the place for ****125, but I made a bridge between the pins.



    www.avelectron.com
    Made in Italy.
    #16
    Jump to:
    © 2019 APG vNext Commercial Version 4.5