This class was written for the Arduino library.
It reads and writes directly to sectors on a sd card.
It's use is for mass storage on the arduino platform.
It's not to store data and then load it(without a special program) to a PC.
Import the library:
#include <SDCARD.h>
It has only two functions:
SDCARD.readblock(sector number); //read 512 bytes from this sector
SDCARD.writeblock(sector number); //write 512 bytes to this sector
The 512 bytes are read/write from a buffer which must be declared as global:
unsigned char buffer[512] ; //contains the 512 bytes to read/write
Operational notes:
The code reads/writes direct to the sectors on the sd card.
It does not use a FAT(always FAT16).
If a 2GB card has been formatted the partition(sector 0), boot (around sector 135),
FAT's(around sectors 100-600) and the root directory(around 600-700) can be written over.
The data in files(above sector 700) can also be written over.
The card can be reformated, but be aware that if the partition(sector 0)
has been written over formating with windows XP or 7 will not restore it.
It will put the boot sector at 0 which can confuse some(not all) programs.
The playground has SDuFAT-basic - library to handle SD cards from Arduino compatible platforms.
This program cannot run when the boot sector is 0.
I have found that my cannon digital camera will restore the partition
and boot to the origional factory conditions.
No doubt there are other format programs which will use a partition sector.
I have previously described this library class.
http://arduino.cc/forum/index.php/topic,8133.0.html
I have made several improvements to the code. It is now faster and can handle
a greater range of sd cards.
It can handle Ver2.00 or later Standard SD Memory Cards.
256 MB, 1.0 and 2.0 GB cards purchased from 2008-2011 work well.
The library and the circuit are in SDCARDsectors.zip
Download if from:
http://code.google.com/p/mysudoku/downloads/list
Paste the folder SDCARD into the library:
C:\arduino-0021\arduino-0021\libraries
Then from the IDE under:
file-examples-SDCARD
You should see two programs:
checksdcard
readwritesector