SD card file system reading

Discussion in 'Embedded Systems and Microcontrollers' started by ssureshtronics, Sep 1, 2010.

  1. ssureshtronics

    Thread Starter New Member

    Sep 8, 2006
    8
    0
    Hello all,

    I've interfaced sd CARD with my MCU C8051F120. i established the communication and i initialised the card too, card responding well and the CSD register gives the information about the size, current, file system, speed.
    I can able to write the data into the particular sectors and also able to read the same written data in the sectors. Here is my question.
    The card was formatted as FAT in PC and a text file was copied in the card, now i want to read exactly the content of the "*****.txt" file in the card.
    Please let me know anybody worked on such a thing. Where the file name details will be stored in the card, and what is descriptor, :confused: in which sector will the file information will be stored.

    I'm using 256MB card, the SPI clk rate was 2 MHz.

    I'll be glad :) for u r valuable replies
     
  2. Vaughanabe13

    Active Member

    May 4, 2009
    102
    5
    This is not something that can be answered easily on a message board. My suggestion is to go read about how the FAT16 file system works. Creating SD libraries for a microprocessor from scratch is NOT fun and extremely time consuming. That's why I use the Microchip MDD File System for all my SD work.
     
  3. Vaughanabe13

    Active Member

    May 4, 2009
    102
    5
    Here is a link to the MDD file system I use:
    http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2680&dDocName=en537999

    Keep in mind this won't work unless you are using a PIC18, PIC24, dsPIC, or PIC32 microcontroller. So it may not be worth it to you to have to learn a whole new device just for this file system.

    Basically you have to install the project files and libraries of the MDD File System, and then you will find an example project for reading and writing to files on a FAT SD card. You can mess around with the example project and see how to use the read and write functions. You can also do stuff like file searching. You can also use the MDD libraries in your own project.

    Another thing you might do is buy this book:
    http://www.amazon.com/Programming-3...=sr_1_1?ie=UTF8&s=books&qid=1283348166&sr=8-1

    He does a pretty good job explaining how the FAT file system works and how to read and write files via SD. But it's all based on the PIC32MX-series of microcontrollers.
     
  4. ssureshtronics

    Thread Starter New Member

    Sep 8, 2006
    8
    0
    Thanks Vaughana

    First I thank for u r suggestion,

    "Creating SD libraries for a microprocessor from scratch is NOT fun and extremely time consuming."

    The FAT16 file formatt is a simple file system which tells the detailed information of the stored files in the media(SD). I just done it all within three days, Now my MCU is reading all the files in the SD, by reading the Boot block and Root directory, Even for Graphical purpose we no need to have a burden of converting BMP to RGB or to HEX. Simply the image can be displayed from the SD by reading the location specified by the Root directory. We have to do is just some manipulation to reverse the RGB information because it stores the LSB as a first byte then continues to MSB.

    Anyway thanks for your suggestion.
    You said you worked on MDD file system, Shall I know the what are all the information will stored for BMP file other width, height, and size.? Because while I read the BMP files certain bytes (15 bytes) has the data of 00, it persists on all the BMP files. I don't know what it meant.
     
  5. mushin123

    New Member

    Aug 28, 2010
    13
    0
    Micro C has a FAT16 file system with source code for 8051. There is also a MMC/SD driver:

    http://www.bipom.com/products/us/202.html

    When you install the software, the sources are under

    C:\bipom\devtools\MicroC\BipomLib\FAT
    C:\bipom\devtools\MicroC\BipomLib\mmc

    and examples under:

    C:\bipom\devtools\MicroC\Examples\8051\medium\FAT\FAT_MMC
     
  6. sandaltan

    New Member

    Feb 3, 2016
    1
    0
    Hi there, I would love to get to the point of your opening remark "I've interfaced sd CARD with my MCU C8051F120". I am trying to do the same thing and struggling with the lack of information available. Are there any SD libraries existing suitable for the C8051F120? I don't think I can go about creating these myself. Thanks!
     
Loading...