• AVR Freaks

Read file off SD card

Author
4rs
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2018/11/15 17:57:38
  • Location: 0
  • Status: offline
2019/11/11 17:20:45 (permalink)
0

Read file off SD card

I have the need to read a data file (address and data values) off a SD card using PIC18F4550 and send the data over to a device over the SPI bus. The SD card will be written to using a Windows PC.   
 
Interfacing to the SD card over SPI should not be an issue but do I have to worry about the FAT32 format in order to select the file and read data off it?  I dont think the PIC18F4550 will have enough memory to support file functions.
#1

5 Replies Related Threads

    ric
    Super Member
    • Total Posts : 24624
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Read file off SD card 2019/11/11 18:12:44 (permalink)
    4 (1)
    Is it really an SD card (all sizes up to 2GB), or actually an SDHC card?
    (They look the same, but are different "under the hood".)
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11430
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: Read file off SD card 2019/11/11 19:18:49 (permalink)
    4 (1)
    do I have to worry about the FAT32 format in order to select the file and read data off it?

     
    If you've put files on the card with a PC, then your PIC needs to understand FAT.  FatFs will easily fit in a 32KB PIC18.
    #3
    Mysil
    Super Member
    • Total Posts : 3483
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: Read file off SD card 2019/11/12 00:02:58 (permalink)
    4 (1)
    Hi,
     
    There is quite a lot of software needed to navigate directories and files of a SD-card.
    You may look up a documentation of the filestructure on Wikipedia.
    Then there is also the details of how to initialize and communicate with the card.
    A SD-card is made to communicate using either a 4 bit parallel interface,
    or as a backup protocol, using ordinary SDI with one input, one output and one clock line.
    There is free documentation of the SDI interface on the website of SD-card Association,
    look for simplified specifications.
    The full specification of all details including the 4-bit interface is only available to those members of SD-card Association that pay fees.
     
    Fortunately, other people have done it before.
    FatFs by ELM-Chan is good, you may see documentation and download software from his website:
    http://elm-chan.org/fsw/ff/00index_e.html
    There is also a version of the same software wrapped as a library in MCC,
    that comes together with SDI driver routines for MSSP peripheral in the PIC18.
     
    Your  PIC18F4550  is quite ancient, and is not supported by MCC directly.
    You may try to create a MPLAB project for PIC18F45K50, 
    and run MCC for that, to create code for MSSP  peripheral using SPI,
    and MCC File system library.
     
    With MCC File System library version 1.0
    you may also want to use MCC Foundation Services library version v0.1.34 from the downloads archive.
    I have not actually tried it.
     
        Mysil
    #4
    4rs
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2018/11/15 17:57:38
    • Location: 0
    • Status: offline
    Re: Read file off SD card 2019/11/12 10:36:00 (permalink)
    0
    This is a micro SD card but I can use any kind of SD card.   Also, I am not restricted to using a PC.  All I need is a means to store data and read it back for use later.
    #5
    jtemples
    عُضْوٌ جَدِيد
    • Total Posts : 11430
    • Reward points : 0
    • Joined: 2004/02/13 12:31:19
    • Location: Southern California
    • Status: offline
    Re: Read file off SD card 2019/11/12 11:36:23 (permalink)
    5 (2)
    Store data from where and read it back from where?
     
    There is no requirement to use FAT on an SD card; you can create your own simple file system or just write raw data.  But you won't be able to read it anywhere else.
    #6
    Jump to:
    © 2019 APG vNext Commercial Version 4.5