Shop OBEX P1 Docs P2 Docs Learn Events
SD Card access — Parallax Forums

SD Card access

PhilldapillPhilldapill Posts: 1,283
edited 2008-01-10 00:12 in Propeller 1
Is there any simple SD Card read/write access objects that aren't totally overwhelming for the beginner? I ran a search on the object exchange and I'm having a hard time finding a simple interface. I just got my sample SD sockets in from molex and made a quick and dirty card adapter for the prop and can't wait to see it working. Any advice/help is appreciated.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-09 06:08
    Rokicki's SD card routines are the most used. There was another set, but I think they were read-only. If you mostly want to test your card, you could try "DongleBasic" from the Object Exchange. It uses the programming port for console I/O and has SD card support like all the FemtoBasic derivatives. It requires no other I/O, but, like FemtoBasic, can do I/O to any pin, manipulate the counters, etc.
  • koko76koko76 Posts: 4
    edited 2008-01-09 06:14
    I'll second that particular object. One think to keep in mind when using that object is to make sure that you have your SD card formatted in FAT16. You can do this under windows if you keep use the command line. My card is drive G so I use:

    Format g: /A:size

    Where "size" is one of the following:

    min max
    4M 512 512
    8M 512 1K
    16M 512 2K
    32M 512 4K
    64M 1K 8K
    128M 2K 16K
    256M 4K 32K
    512M 8K 32K
    1G 16K 32K
    2G 32K 32K

    That table is from http://tomas.rokicki.com/fat16work/README.txt which is his documentation on that code.
    This had me pretty stumped with the routine hanging and not completing until I fixed the format.
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-01-09 06:25
    I JUST got this new 512MB SD card an hour ago. I don't have an SD card reader that connects to my computer. Do I need to format it through my computer before I can use it with the prop?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-09 06:41
    Either it will work or it won't. Try it. The worst that will happen is that it won't work and the file structure will get screwed up (not likely) and you'll have to reformat it. Of course it could always catch fire or explode or melt suddenly, but probably not.
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-01-09 07:38
    Good god... Is there any sort of simple demo for the dongle basic? This is overwhelming and I'm not sure where to begin... I'm thinking that in Start in DongleBasic.spin, Right before the last repeat block, I need to insert my mass.mountSDVol code and open a file somehow???
  • RaymanRayman Posts: 14,162
    edited 2008-01-09 13:03
    Rockiki's files come with a test program...

    I have more info·here:

    http://www.rayslogic.com/propeller/Programming/SD_Card/SD_Card.htm
  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-09 14:19
    DongleBasic already does a mount of the SD card when it opens a file for whatever reason. There's an OPEN statement (line 743) that mounts the card, then opens a file on it. There's a CLOSE statement (line 837) that closes the file. The READ (line 760) and WRITE (line 789) statements and the FILE "pseudo-variable" (lines 427 and 1079) read or write bytes to the opened file.
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-01-09 21:50
    OK, so here's an update...

    I got an SD Card reader today. It's a thumb drive adapater where you just plug the sd card into it, and plug the adapater into the USB port and it acts like a thumb drive.
    The computer recognized it and reads it fine. I formatted it and the only two options where FAT and FAT 32. I assume FAT is FAT16.
    I then tried my card with the prop and it's still giving me error a weird error number that is not in the PUB mount function. When I do:
    TV.dec(\mass.mountSDVol(def#spiDO,def#spiClk,def#spiDI,def#spiCS))
    It prints -12208 on the screen. This is with or without the card installed. When I take the pull-up resistors off of pins 8-11, it then gives error -20. ANY idea what's wrong???
  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-09 21:57
    The -12208 is minus the address of a descriptive text string (do TV.str(||\mass.mountSDVol ...)) to see it. The -20 is an "Invalid SD card" sort of message. I've gotten that when the SD card is formatted improperly for some reason. Check your wiring though.
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-01-09 22:04
    Yeah, I wish I could take a picture of this beast. It's kinda ugly but I checked the connections with an ohm meter and it seems to be ok... I have 4 more sockets and plenty of protoboard so I think I'll just make a new one "just in case". Thanks Mike.
  • PhilldapillPhilldapill Posts: 1,283
    edited 2008-01-10 00:12
    Just to clarify, every pin on the SD card has a pull up or pull down resistor? My current setup has 20K pull up resistors attached to everything but Ground. In addition, do I need resistors between P8..P11 and the pins on the SD? If so, what size?
Sign In or Register to comment.