Shop OBEX P1 Docs P2 Docs Learn Events
Writing and Reading SD/MMC cards — Parallax Forums

Writing and Reading SD/MMC cards

El PaisaEl Paisa Posts: 375
edited 2007-03-03 18:08 in Propeller 1
Is there a program to perform operations such as write, read, create directories, open files, etc for the Spark Fun breakout SD/MMC cards?

Comments

  • fred2fred2 Posts: 47
    edited 2007-02-26 21:17
    Great question!

    Just received mine in the mail today...

    fred2
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-02-26 21:19
    Yes, rokicki made one, it's (presently) near the bottom of this page (http://forums.parallax.com/showthread.php?p=622673), and its in the object exchange as well.

    At present it does not support subdirectories.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.

    Post Edited (Paul Baker (Parallax)) : 2/26/2007 9:24:40 PM GMT
  • rokickirokicki Posts: 1,000
    edited 2007-02-26 21:57
    And I am always soliciting comments on improvements that could be made, so feel free to drop me a line.

    Note that it does not support MMC at this point.
  • David BDavid B Posts: 591
    edited 2007-02-26 22:31
    Rokiki, your code currently only allows a single file to be open at a time, right?

    I have a new project where I need to have two or more, but probably just two, files open for reading simultaneously but repeatedly at random times. This is for an exhibit where pushbuttons will play WAV sounds.

    Do you think it would be hard to modify your code for this?
  • rokickirokicki Posts: 1,000
    edited 2007-02-26 23:08
    Yes, one file open at a time right now.

    I've group the variables that are per-file, so it should not be *too* hard to make it work with multiple files. I am
    undecided on exactly how to approach this though. Let me think about it just a little bit.

    Note that the SD support is slower than what you might be used to on a PC; playing a WAV should be possible,
    but playing two WAVs simultaneously (assuming 44.1KHz 16-bit stereo samples, so that's 176KB/sec with
    enough buffering to overcome jitter, *each*) might be pushing it. I mean, I am sure it is possible, but
    you will have to be careful.

    If you are willing to prepare the card carefully, by formatting it fresh, then writing each file in order (to
    guarantee each file is fully sequential), you can eliminate all the file system overhead and just go straight to
    the lowest level block reading code; that would probably be the easiest way of doing what you want, but
    again, it would only work if you prepared the card in that way. If you did this, you would start by opening
    each file in turn, and then get (with a new routine) the block offset of the first block, and the total file
    size, of each file into an array. Then you would just read blocks off the low level card.

    This would also be a very simple modification to what exists.

    But let me know in more detail what your requirements are and I'm sure we can get it to work. In
    particular, I can make the block read code faster than it currently is if you are willing to give up a bit
    more code space.

    If you use one of the compression codecs people have posted on this forum, you might be able to do it
    more easily, but certainly I'd just start with WAVs and see what happens.
  • El PaisaEl Paisa Posts: 375
    edited 2007-02-26 23:29
    Thanks.
    SDRW.spin·works perfectly with my setup, BTW femtobasic (any version) does not, shows a error message "can't mount the SD".

    ·
  • El PaisaEl Paisa Posts: 375
    edited 2007-02-26 23:42
    I try sdrw_test.spin. It reads directories, writes and reads· but not allow to use my own commands.

    I would like a program to open/close files, create directories, create files, open and close files, etc.
  • Mike CookMike Cook Posts: 829
    edited 2007-02-26 23:44
    Check the CON block in the first part of FemtoBasic.spin, and set 'true' for·whatever·platform your using.
    con
       Demo      = true                   ' Demo Board
       Proto     = false                   ' Proto Board
       Hydra     = false                   ' Hydra
    

    For the Demo board the SD Card uses pins 0..3, ProtoBoard uses pins 8..11, and Hydra uses pins 16..19

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Mike
  • mahjonggmahjongg Posts: 141
    edited 2007-02-27 01:17
    FemtoBasic uses the SPI interface mode, so it has an integrated SPI interface.

    SPI mode is a bit slower than the alternative "multi-bit" mode, and somewhat less flexible, but the advantage is that only four I/O lines are needed, mult-bit modes need a lot more I/O pins.

    Mahjongg
  • inserviinservi Posts: 113
    edited 2007-02-27 11:01
    Hi rokicki.

    I tried your objects for reading/writing SD cards. I is a really great work !
    It add a great value for the Propeller.

    Congratulation and thank-you.

    dro.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    in medio virtus
  • rokickirokicki Posts: 1,000
    edited 2007-02-27 17:05
    Thanks! That's a cool thing about the propeller; with everyone contributing something, there are a lot of
    prewritten pieces all ready to go.
  • El PaisaEl Paisa Posts: 375
    edited 2007-03-03 16:05
    Great work.

    Any chance to add a "append" to the "read, write" file operations?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-03 16:34
    It's already there. I haven't really tested it since it's just passed on to Rokicki's FAT routines. Let me know if there are any problems.
  • El PaisaEl Paisa Posts: 375
    edited 2007-03-03 17:58
    Thanks Mike.

    The version I have does not , may be I have an outdated file.
  • El PaisaEl Paisa Posts: 375
    edited 2007-03-03 18:08
    Thanks again Mike.

    I just downloaded the latest object file and works...
Sign In or Register to comment.