Acessing SD card without using Sd.h

New to programming. Need help accessing SD Card directly from SPI without using Sd.h or any custom made libraries.

Thanks

New to programming. Need help accessing SD Card directly from SPI without using Sd.h or any custom made libraries.

I wouldn't recommend that you try this but here is what you need to do.

Read this https://www.sdcard.org/downloads/pls/simplified_specs/part1_410.pdf first. The SD SPI protocol is covered in section 7.

Then write your own code to access the SD.

I've been thinking about this recently.

As far as I can see if you want the SD Card to be readable on a PC the simplest thing is to use one of the existing libraries. There is a lot of complication in writing the data correctly to the FAT file system.

If you only want to use the SD Card on the Arduino there seems to be nothing to stop you programming it directly with the SPI interface in a much simpler way without bothering with a file system. However you will still need to deal with the formal interface of the SD Card system.

If you only need to store a small amount of data an I2C EEPROM might be an easier and cheaper option.

...R

SDfat.h by member fat16lib is a good choice for SD access. Download it here.
http://code.google.com/p/sdfatlib/

Thank you all for helping.
I think i bit off more than i could chew.

You can use the SD driver from SdFat to read and write blocks on an SD without a file system.

Here is example code that writes a block then reads it back.

#include <SdFat.h>
const uint8_t CS_PIN = 10;
Sd2Card card;
uint8_t block[512];
uint32_t address = 12345L;
void setup() {
  Serial.begin(9600);
  if (!card.begin(CS_PIN)) Serial.println("begin error");
  
  if (!card.writeBlock(address, block)) Serial.println("write error");

  if (!card.readBlock(address, block)) Serial.println("read error");
  Serial.println("Done!");
}
void loop() {}

The total size of this sketch is about 3,900 bytes, about 2,000 extra bytes for card read/write.

Binary sketch size: 3,888 bytes (of a 32,256 byte maximum)