Shop OBEX P1 Docs P2 Docs Learn Events
Need help writing to SD card — Parallax Forums

Need help writing to SD card

bulkheadbulkhead Posts: 405
edited 2008-09-21 02:00 in Propeller 1
I couldn't find a single good source of info on how to do it (I tried the Object Exchange, forum search, search.parallax.com). If there is such a source, could someone point me to it?

So far, I have unsuccessfully used the pinout shown on the Propeller Cookbook (image attached) and the "fsrw.spin" object (attached) with the pin connections shown in "sdspiqasm.spin" (with the exception that I used 1kR instead of 20kR). I then attempted to run it with the code from this post: http://forums.parallax.com/showthread.php?p=746399

The result was the program hung up on the line
sdfat.mount(0)

and my PC no longer "sees" the SD card when I plug it in. I had just formatted the SD card and verified that it worked with the PC before I attempted the write, so the propeller definitely did something. Is it a software/hardware problem?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'm new to the propeller!
705 x 266 - 33K

Comments

  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-09-20 02:09
    Bulkhead,

    you might check out the following link for some basic code that gives an example of how to set up an SD program from SPIN. One of the examples (Simonl's) simply calls some of the software available on the Object Exchange, "fsrw and friends." It's very basic but gives you an idea of where to start. His particular example writes files in CSV format.

    http://forums.parallax.com/forums/default.aspx?f=25&m=288797

    {Edit note: I just noticed that this is the part of the forum you already tried. Hmmm.... and you did verify that the card was okay before using it on the Prop. Well, in that case you might be in the same boat I am with a mystery of how my software, which calls up fsrw, etc. is completely trashing my SD cards. In that case, I should like to invite you to join in on an on-going discussion on the forum at

    http://forums.parallax.com/forums/default.aspx?f=25&m=294690 }

    Make sure all of the objects that are called by fsrw, etc are in your Propeller folder or on your Propeller IDE when you download it so they, too, will get downloaded into the Prop.

    As for your PC no longer seeing the SD card, it's possible that because the files on the SD card weren't closed out properly when you ran the Propeller, the PC doesn't see the card. I had the same problem when I started out with SD cards and my program wasn't yet operating properly. Your bad software writes garbage to the SD card and the garbage smells bad to the PC. I had to try plugging the card into my SD adapter and then plugging the adapter into the computer. Sometimes I had to do that several times before it showed up. You might have to use something like Norton's Disk Doctor, etc. before you can see it, too, if things got really bad. After unsuccessfully running a card on your Propeller - even if only once - you will probably have to reformat the SD card so your Propeller can work with it. It's a bummer when having to do that after every debugging operation, but after a while you will develop a technique that you can do in your sleep. Sooner or later, you will get your software to close out the files properly and it won't be a problem, hopefully.

    Hope that helps,
    Mark

    Post Edited (ElectricAye) : 9/20/2008 2:17:06 AM GMT
  • bulkheadbulkhead Posts: 405
    edited 2008-09-20 20:52
    ElectricAye, which SD card socket are you using, and do you have a schematic for it? I am thinking my problem is a hardware issue since all I did was unsolder the socket directly from a USB reader and solder on a header, along with many pull-up resistors, the placement of which I am weary about. I am using the "fsrw and friends" object and Simonl's example code which is supposed to work.

    Actually I just realized I haven't been using the latest version of fsrw. Apparently it didn't come up when I searched the Object Exchange for "SD card" since it is listed in full as "secure digital card". I will give it a try. For future reference fsrw can be found here: obex.parallax.com/objects/92/

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm new to the propeller!
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-09-20 21:12
    Sounds like you are fighting on two fronts at once.. Hardware and Software.

    Use something that is a "known" working software solution like FemtoBASIC to do
    your hardware testing, then move forward once you know thats working..

    Otherwise, you'll be removing handfuls of hair.. [noparse]:)[/noparse]

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Getting started with a Propeller Protoboard?
    Check out: Introduction to the Proboard & Propeller Cookbook 1.4
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
  • ElectricAyeElectricAye Posts: 4,561
    edited 2008-09-21 02:00
    Bulkhead,
    I've been using an SD socket "breakout board" I bought from Sparkfun.com. It has solder holes for the various lines DO, DI, CLK, etc. See....

    http://www.sparkfun.com/commerce/product_info.php?products_id=204


    As far as schematics go, I used the same schematic and resistors as shown in the wiring diagram at the top of the sdspi object which I think came with "fsrw and friends." I have attached a scan of it for your convenience.

    hope that helps,

    Mark
    1757 x 830 - 682K
Sign In or Register to comment.