SEEED SD Card Shield and the ardunio mega 2560

I asked the ardunio forums and they don’t seem to have any idea on how to fix this. I googled this problem and saw people having it but they never responded with how they fixed it if they did. I loaded up sdinfo.pde (I didn’t edit it at all) with a 2gb SD card inserted. After finally getting the thing to compile I got the error

"
SdFat version: 20111205

type any character to start

card.init failed
SD errorCode: 0X1
SD errorData: 0X0

type any character to start
"

I have no idea what this means or how to fix it. Please help.

Hi,

SD Card Shield is a Arduino Uno compatible Shield , it use SPI protocol to communication with Arduino , but the SPI interface on Arduino Uno is different from Arduino Mega. Hence , you can’t make SD Card Shield work by stacking it on Arduino Mega. As to the interface difference between Arduino Uno and Mea, please refer to the information on Arduino website.

Regards,
Deray

the SD card shield3.0 is not compatible with mega2560. you can refer to seeedstudio.com/wiki/SD_Card_Shield_V3.0 for details. seeed has designed the SD card shield 4.0, which would compatilble with mega2560

Well how am I suppose to know that from the package? It seems to imply that it works with all arduino on the package quote “ardunio compatible” us the first feature on the list. It doesn’t seem to suggest any particular arduino doesn’t work. What ardunios does it work with are there any others I should not buy to not waste money? The Uno works but what else? In addition I’m using the TFT 2.8" touch screen (which version I don’t know because there appears to be no marking indicating which) are there any ardunios that are compatible with both of the shields? Because what you guys seem to be saying there is no ardunio that is compatible with both of the two shields. How am I suppose to know this before I buy this? How am I suppose to know that I need to check a wikipedia page before buying this?

Hi, we are a company that can provide you the driver and basic software(like libraries and some codes) .You know , Arduino/Seeeduino is different from Mega , you need modify program and it’s not too hard for us.

So, “ardunio compatible” means that we can use Arduino or Mega , but sometimes we would change a little of program.

If you do not know how to modiy it’s code, you can put your question on our forum , we are a open source hardware company, we can discuss it together, don’t we?

Thanks a lot for your comprehension.

That would be wonderful thank you. I am unable to figure out what exactly I need to do to fix the SEEED sd card shield so it will preform its function with my ardunio mega 2560. As I said in the original post I don’t know what the error means. My suspicion is that my board is not comparable with the mega. I haven’t done anything eight the card except attempt to run the provided libararies on the wiki. An example code that works with the seeed sd shield and my ardunio mega would be incredabily helpful. Thank you.

which said on our wiki for SD Card Shield v3.

So if your SD Card Shield is the version of 3.0 , it’s not compatible ,and you will get some errors like it you have posted

But our SD Card Shield 4.0 is compatible with Mega.

And our Music Shield is compatible with Arduino and Mega, but for Mega, you need modify the program. In fact , we’ll remind customer on our Home Page or Wiki if this product is not compatible with Mega.

Right I realize that on the wiki it says that but on the package it gives no indication that it is not usable with the arduino mega. How am I suppose to know if I’m at the store that it will be not compatible with my device? I would have to know that the wiki existed before having even bought one of your products. It’s a bit misleading.

The touch screen I have only seems to work with the Mega 2560 (I think the wiki is fairly hard to decipher at times). The SD card shield that I have only works with the Uno meaning that these parts are useless in combination with each other. Am I correct in thinking that the TFT 2.8" touch screen only works with Mega and the Seeedunio mega?

Hi,sorry for that , may we need post “Do not compatible with Mega” on the package .

TFT Touch shield can compatible with Arduino and Mega.

In fact , we need time to promote our product, like SD Card v4.0 or TFT Touch Shield v2.0 , but as a maker, we can use shift register to expand SD Card v3.0. So everything has its’ function , maybe we just need time to know what problems are existed and fine down it. Thanks for comprehension.

Hey,

I purchased the SD shield for my Mega 2560, and I think I got it working. The issue is pretty straightforward, the SD card shield uses the SPI interface. That interface on most Arduinos in used on pin 10-13. On the Mega 2560 It’s on pin 50-53.

MEGA 2560
SPI: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS).

UNO
SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK).

Now I’m assuming you can wire these pins and the power separately and get it work. However, that would be too ugly for me. I read the documentation for the SD card library and apparently this is a known issue. They have a work around that can easily be enabled, They call it “Soft SPI”. I don’t know if you will experience a performance issue but you should at-least get the functionality.

The changes that you need to make are these lines in the SdFatConfig.H file.

#define MEGA_SOFT_SPI 0
#define USE_SOFTWARE_SPI 0

to

#define MEGA_SOFT_SPI 1
#define USE_SOFTWARE_SPI 1

Save, and restart the Arduino Envoirment if it was open.

I don’t know if this will solve all your issues or if it will create new ones for you down the road. I take no responsibility if there is any sort of damage due to these modifications. I would like later tonight to bridge the arduino with wires to the shield and see if I can use the native libs. I wanted to include the links to the arduino site directly, Apparently I get a message that says “Your post looks too spamy for a new user, please remove off-site URLs.” So please verify them before you use the information.

Happy Modding!

I found the Bench example available with the library. I’m using the Arduino Mega 2560, SD shield, and a ScanDisk SDHC 16GB class 4 card. This is simply what I had lying around.

The Bench Example yielded these results.

SOFT SPI as described above
Type any character to start
Free RAM: 6657
Type is FAT32
File size 5MB
Starting write test. Please wait up to a minute
Write 62.56 KB/sec
Maximum latency: 77100 usec, Avg Latency: 1593 usec

Starting read test. Please wait up to a minute
Read 94.75 KB/sec
Maximum latency: 9824 usec, Avg Latency: 1050 usec

Done

Wiring pins directly to Mega (50-53)
Type any character to start
Free RAM: 6657
Type is FAT32
File size 5MB
Starting write test. Please wait up to a minute
Write 136.34 KB/sec
Maximum latency: 39440 usec, Avg Latency: 728 usec

Starting read test. Please wait up to a minute
Read 255.34 KB/sec
Maximum latency: 3156 usec, Avg Latency: 387 usec

Done

Basically 2.5x better performance by using re-wiring, although I lose the shield stackability.

That’s great!Sounds right,let’s have a thinking.

Alright so sorry for bringing this thread back but I have an update. I bought an ardunio uno as requested. Everything seems to be working a lot better now. BUT its still not working perfectly. By using the script on the website I’ve been able to make some progress I make sure the images are named right and are 16 bit but regardless of what I do I seem to have an issue with the screen distorting horribly when running the tftbmp sketch. Here is an example of what the screen does i.imgur.com/kIFizQY.png Occasionally the screen will just be completely black.

If you notice the only difference between this and the original is that I changed the pins to 10 instead of 53. Since the uno doesn’t have a pin 53 I figured this has to be incorrect and indeed it was. Now I do get things on the screen but its all garbled (unlike before when nothing would come up). By editing it it seems to allow it to access the sd card here is the current adaptation.

[code]// This sketch is adapted to Seeed’s TFT library from
// https://github.com/adafruit/TFTLCD-Library/blob/master/examples/tftbmp/tftbmp.pde
// by ladyada/adafruit under MIT license

#include <SD.h>
#include <TFT.h>

// In the SD card, place 24 bit color BMP files (be sure they are 24-bit!)
// the file itself
File bmpFile;

// information we extract about the bitmap file
int bmpWidth, bmpHeight;
uint8_t bmpDepth, bmpImageoffset;

void setup()
{
Serial.begin(9600);

Tft.init();

Serial.print(“Initializing SD card…”);
pinMode(10, OUTPUT); //53 is used as chip select pin

if (!SD.begin(10)) { //53 is used as chip select pin
Serial.println(“failed!”);
return;
}
Serial.println(“SD OK!”);

}

void loop()
{
Tft.setOrientation(0);

//Image 1
bmpFile = SD.open(“flower.bmp”);
if (! bmpFile) {
Serial.println(“didnt find image”);
while (1);
}

if (! bmpReadHeader(bmpFile)) {
Serial.println(“bad bmp”);
return;
}

Serial.print("image size “);
Serial.print(bmpWidth, DEC);
Serial.print(”, ");
Serial.println(bmpHeight, DEC);
bmpdraw(bmpFile, 0, 0);
delay(3000);
bmpFile.close();

//Image 2
bmpFile = SD.open(“hibiscus.bmp”);
if (! bmpFile) {
Serial.println(“didnt find image”);
while (1);
}

if (! bmpReadHeader(bmpFile)) {
Serial.println(“bad bmp”);
return;
}

Serial.print("image size “);
Serial.print(bmpWidth, DEC);
Serial.print(”, ");
Serial.println(bmpHeight, DEC);
bmpdraw(bmpFile, 0, 0);
delay(3000);
}

/*********************************************/
// This procedure reads a bitmap and draws it to the screen
// its sped up by reading many pixels worth of data at a time
// instead of just one pixel at a time. increading the buffer takes
// more RAM but makes the drawing a little faster. 20 pixels’ worth
// is probably a good place

#define BUFFPIXEL 20

void bmpdraw(File f, int x, int y) {
bmpFile.seek(bmpImageoffset);

uint32_t time = millis();
uint16_t p;
uint8_t g, b;
int i, j;

uint8_t sdbuffer[3 * BUFFPIXEL]; // 3 * pixels to buffer
uint8_t buffidx = 3*BUFFPIXEL;

for (i=0; i< bmpHeight; i++) {

  Tft.setXY(x, y+bmpHeight-i); 


for (j=0; j<bmpWidth; j++) {
  // read more pixels
  if (buffidx >= 3*BUFFPIXEL) {
    bmpFile.read(sdbuffer, 3*BUFFPIXEL);
    buffidx = 0;
  }
  
  // convert pixel from 888 to 565
  b = sdbuffer[buffidx++];     // blue
  g = sdbuffer[buffidx++];     // green
  p = sdbuffer[buffidx++];     // red
  
  p >>= 3;
  p <<= 6;
  
  g >>= 2;
  p |= g;
  p <<= 5;
  
  b >>= 3;
  p |= b;
 
   // write out the 16 bits of color
  Tft.sendData(p);
}

}
Serial.print(millis() - time, DEC);
Serial.println(" ms");
}

boolean bmpReadHeader(File f) {
// read header
uint32_t tmp;

if (read16(f) != 0x4D42) {
// magic bytes missing
return false;
}

// read file size
tmp = read32(f);
Serial.print(“size 0x”); Serial.println(tmp, HEX);

// read and ignore creator bytes
read32(f);

bmpImageoffset = read32(f);
Serial.print("offset "); Serial.println(bmpImageoffset, DEC);

// read DIB header
tmp = read32(f);
Serial.print("header size "); Serial.println(tmp, DEC);
bmpWidth = read32(f);
bmpHeight = read32(f);

if (read16(f) != 1)
return false;

bmpDepth = read16(f);
Serial.print("bitdepth "); Serial.println(bmpDepth, DEC);

if (read32(f) != 0) {
// compression not supported!
return false;
}

Serial.print("compression "); Serial.println(tmp, DEC);

return true;
}

/*********************************************/
// These read data from the SD card file and convert them to big endian
// (the data is stored in little endian format!)

// LITTLE ENDIAN!
uint16_t read16(File f) {
uint16_t d;
uint8_t b;
b = f.read();
d = f.read();
d <<= 8;
d |= b;
return d;
}

// LITTLE ENDIAN!
uint32_t read32(File f) {
uint32_t d;
uint16_t b;

b = read16(f);
d = read16(f);
d <<= 16;
d |= b;
return d;
}

[/code]

By checking the serial monitor I get this

Initializing SD card...SD OK! size 0x27DB6 offset 54 header size 40 bitdepth 16 compression 40 image size 240, 340 2051 ms size 0x25836 offset 54 header size 40 bitdepth 16 compression 40 image size 240, 320 1929 ms size 0x27DB6 offset 54 header size 40 bitdepth 16 compression 40 image size 240, 340 2051 ms size 0x25836 offset 54 header size 40 bitdepth 16 compression 40 image size 240, 320 1931 ms size 0x27DB6 offset 54 header size 40 bitdepth 16 compression 40 image size 240, 340 2051 ms size 0x25836 offset 54 header size 40 bitdepth 16 compression 40 image size 240, 320 1932 ms size 0x27DB6 offset 54 header size 40 bitdepth 16 compression 40 image size 240, 340