View Full Version : SD Card access
01-09-2008, 02:03 PM
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.
01-09-2008, 02:08 PM
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.
01-09-2008, 02:14 PM
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:
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.
01-09-2008, 02:25 PM
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?
01-09-2008, 02:41 PM
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.
01-09-2008, 03:38 PM
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???
01-09-2008, 09:03 PM
Rockiki's files come with a test program...
I have more infoˇhere:
01-09-2008, 10:19 PM
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.
01-10-2008, 05:50 AM
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:
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???
01-10-2008, 05:57 AM
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.
01-10-2008, 06:04 AM
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.
01-10-2008, 08:12 AM
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?