Help, SD CARD INITIALIZATION FAILED..

I have a 3.5 inch TFT 320X480 lcd screen with built in sd card module, Its plug directly to my arduino mega. I am using a kingston 2GB micro sd card.

Here is my sketch I uploaded in my Arduino mega.

#include <SdFat.h>
#include <UTFT_SdRaw.h>
#include <UTFT.h>
#include <URTouch.h>

UTFT myGLCD(CTE35IPS, 38, 39, 40, 41);
URTouch  myTouch(6, 5, 4, 3, 2);
UTFT_SdRaw myFiles(&myGLCD);

// SD chip select pin
const uint8_t chipSelect = 53;

// file system
SdFat sd;

void screenHome()  // draw main home screen showing overview info
{
  myGLCD.clrScr(); // clear the screen
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawLine(0, 360, 800, 360); // draw line above dock
  int mytime = millis();
  int ret = myFiles.load(0, 0, 800, 480, "demo.raw", 16);
  Serial.println(millis() - mytime);
  Serial.println(ret);
}

void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for DUE & Leonardo only
  }
  Serial.println(F("Initialising SD card..."));
  bool mysd = 0;
  // see if the card is present and can be initialized:
  while (!mysd)
  {
    if (!sd.begin(chipSelect, SPI_HALF_SPEED)) {
      Serial.println(F("Card failed, or not present"));
      Serial.println(F("Retrying...."));
    }
    else
    {
      mysd = 1;
      Serial.println(F("Card initialised."));
    }
  }
  Serial.println(F("Initialising LCD."));
  myGLCD.InitLCD();
  myGLCD.clrScr();
  Serial.println(F("LCD initialised."));
  screenHome();
}

void loop()
{
}

After uploading . I got this message in my serial monitor:
Card failed or not present!
Retying.........

I am sure that my sd card is in good condition. I cannot figure out what is the problem? Please anyone here please help me. Its frustrating :frowning: Im going to attached the image of my lcd screen .

#define CTE35IPS		27	// R61581	(16bit)

You have a Mcufriend shield. I doubt that it has a Renesas R61581 controller.
UTFT is only supposed to be used with certain makes and models e.g. ColdTears, Itead, ...

The microSD will NEVER work reliably on Mcufriend Mega boards with 7 resistor-packs.
The electrical design is WRONG on the Mega2560 Shield. It has a 10k resistor pack on the SD signals.

The microSD works on ALL Mcufriend Uno Shields. It probably works on Mcufriend Mega2560 boards with 4 resistor-packs.

Buy a different Shield.

David.

@David , can I buy a separate sd card module ? like this one in the link below ?

and connect it to my mega board ?

Actually I just want to put more pictures to display in my LCD but i think mega cannot handle more bytes. So i decided to use sd card. Is there any way to display more images in my screen in smaller size that the mega can handle using its flash memory and without using sd card ?

You can store several colour JPEG images in a mega2560.
You can store quite a few monochrome bitmaps in a mega2560.
You can store even more in a Due.

If you want to display an (almost) infinite number of images, buy a display with properly connected SD card.

As always, post your project requirements e.g. number and type of images.

David.

@David, Therefore what you are saying is that my Mcufriend lcd sd card is not working properly in mega by default ? So I need to contact the store where i brought this one and change to another lcd that is working ?

Mcufriend shields have always had several "electrical" issues. Even the Uno shields.

The 7-RP, 6-RP, 5-RP Mega2560 shields will never work with the SD because the RP on the SD lines is too high resistance.
Newer 4-RP Mega2560 shields will probably work (because they do not have series resistors on the SD lines).

You can ask your shop for a replacement. Watch out for low flying pigs.

UTFT supports certain manufacturers with proven quality.
Mcufriend shields are CHEAP.

If you want to know whether a shield works, post a photo/link to the pcb.

David.