Pages: [1]   Go Down
Author Topic: Problemas al leer SD Initializing SD card...initialization failed!  (Read 970 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hola, Gracias por adelantado.
Tengo una target SD 128M  pruebo el ejemplo read/write  i me funciono una sola vez, i ahora me aparece el siguiente error:

Initializing SD card...initialization failed!

 ayer con otro ejemplo de la Sd me funcione pero no consigo k me vuelva a funcionar. La SD va isertada dentro de una Tft 2,8" Toush shield V2 col.locada directamente encima del arduino i los pins son los siguientes:
D4 :TF_CS, SD card select input pin
D5 :TF_CS,TFT Chip select input pin
D6:TF_D/C, TFT Data/Command control pin
D7: BACKLIGHT,TFTbacklight control pin

Pins used for SPI INTERFACE

D10: SPI Chip Select
D11: SPI Data pin
D12: SPI serial clok pin
A0,A1,A2,A3 Touch Screen ...

El  programa es el de la libreria i es el siguiente:



/*
  SD card read/write
 
 This example shows how to read and write data to and from an SD card file    
 The circuit:
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4
 
 created   Nov 2010
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe
 
 This example code is in the public domain.
    
 */
 
#include <SD.h>

File myFile;

void setup()
{
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.print("Initializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
  // or the SD library functions will not work.
   pinMode(10, OUTPUT);
   
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
 
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("test.txt", FILE_WRITE);
 
  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
   // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
 
  // re-open the file for reading:
  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");
   
    // read from the file until there's nothing else in it:
    while (myFile.available()) {
       Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
     // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop()
{
   // nothing happens after setup
}
Logged

Spain
Offline Offline
God Member
*****
Karma: 25
Posts: 956
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Esa shield lleva todo integrado por lo que descarto un problema hardware...

Me temo que puede haber sido un fallo de escritura en la tabla de asignacion de archivos de la sd y este corrupta.

Lo bueno es que eso lo puede solucionar con un formateo.

Pillate un lector de SD o si tienes uno en el PC y formatea la tarjeta en fat16, hay utilidades en internet especificas para eso.

Por lo que comentas es lo que mas pinta tiene de haber pasado.

Un saludo.
Logged

CUIDADO !! MIS POST NO SON APTOS PARA MENORES. SI ERES MENOR DE 14 AÑOS DEBES DE LEERLOS ACOMPAÑADO DE UN ADULTO

Offline Offline
Full Member
***
Karma: 1
Posts: 208
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hola, Gracias por adelantado.
Tengo una target SD 128M  pruebo el ejemplo read/write  i me funciono una sola vez, i ahora me aparece el siguiente error:

Initializing SD card...initialization failed!

 ayer con otro ejemplo de la Sd me funcione pero no consigo k me vuelva a funcionar. La SD va isertada dentro de una Tft 2,8" Toush shield V2 col.locada directamente encima del arduino i los pins son los siguientes:
D4 :TF_CS, SD card select input pin
D5 :TF_CS,TFT Chip select input pin
D6:TF_D/C, TFT Data/Command control pin
D7: BACKLIGHT,TFTbacklight control pin

Pins used for SPI INTERFACE

D10: SPI Chip Select
D11: SPI Data pin
D12: SPI serial clok pin
A0,A1,A2,A3 Touch Screen ...

El  programa es el de la libreria i es el siguiente:



/*
  SD card read/write
 
 This example shows how to read and write data to and from an SD card file    
 The circuit:
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4
 
 created   Nov 2010
 by David A. Mellis
 modified 9 Apr 2012
 by Tom Igoe
 
 This example code is in the public domain.
    
 */
 
#include <SD.h>

File myFile;

void setup()
{
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.print("Initializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
  // or the SD library functions will not work.
   pinMode(10, OUTPUT);
   
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
 
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("test.txt", FILE_WRITE);
 
  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
   // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
 
  // re-open the file for reading:
  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");
   
    // read from the file until there's nothing else in it:
    while (myFile.available()) {
       Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
     // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop()
{
   // nothing happens after setup
}



Yo tengo la tft 3.2" y no consigo que funcione, eso si yo no tengo la shield de conexion, sabes algo de esa pantalla?
Logged


Pages: [1]   Go Up
Jump to: