This class was written for the Arduino library.
It creates text files and appends data to them.
It's use is for mass storage on the arduino platform.
This data is then loaded onto and used on a PC.
Paste the folder SDCARDFILES into the library then Import:
It has only two functions:
SDCARDFILES.createfile(); //create a text file with 0 length
SDCARDFILES.fileappend(); //append 512 bytes to the open file
The 512 bytes are written from a buffer which must be declared as global:
unsigned char buffer ; //contains the 512 bytes to write to file
This library is based on the SDCARD library :http://arduino.cc/forum/index.php/topic,52871.0.html
It works on standard SD cards from 256MB to 2GB made between 2007-2011.
Start with a newly formatted(FAT16) card.
The first call of createfile will create a text file in the first root directory location:
DATA0000.TXT it will have length = 0
Further calls will create sequential number files up to the maximum allowed in
the root directory(usually 512):
DATA00511.TXT it will have length = 0
Calls to fileappend will write the 512 byte buffer to the end of the currently
Further calls will append until the data sectors are used up.
Both createfile and fileappend use the 512 byte buffer.
It will be changed after the call.
You should use multiples of the cluster size to use the card efficiently.
To help with this and other decisions about your program use the example
SDCARDbootrecord to get this information(2Gb card):
bootsector = 251
partitionsectors = 3962629
bytespersector = 512
sectorspercluster = 64
reservedsectors = 1
fatcopies = 2
rootdirnumber = 512
sectorsperFAT = 242
totalfilesectors = 3962629
FAT1start = 252
FAT2start = 494
rootdirectorystart = 736
datastartsector = 768
clusterbytes = 32768
maximumdataclusters = 61904
maximum clusters per file spread over all files = 120
The class uses 70 bytes of RAM, 2960 bytes of program FLASH.
Of course you must use 512 bytes of RAM for the buffer.
On average a file append takes 60 ms.
Other example programs in the library are:
SDCARDdump: prints one sector. 32 bytes per line
These programs write to the SD card.
SDCARDwritesector: writes one sector on the SD card
Create512files: create 512 text files DATA0000.TXT - DATA0511.TXT
each file is one sector(512 bytes) long.
Download SDCARDFILESpack.zip from:http://code.google.com/p/mysudoku/downloads/list