SD Card Format Problem

Hello Community,

I started to log data with a breakout board. I am working with the Arduino Due. I formatted the SD card and did everything as recommended here:

Nevertheless, after some time of trying the system, it won’t work anymore and when checking the SD card with the arduino example CARDINFO, it tells me that my sdcard is not formatted. Does anyone have any ideas, how this can happen? What can I probably do wrong that this happens all the time at some point?

The wiring should be good, since it all works in the beginning. I am mainly “playing around” with three codes: the CARDINFO example, this here:

include <SD.h>
 
File myFile;
 
void setup()
{
  Serial.begin(9600);
  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(10)) {
    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("nexttest.txt", FILE_WRITE);
 
  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to nexttest.txt...");
    myFile.println("testing 1, 2, 3.dvga");
  // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening nexttest.txt");
  }
}
 
void loop()
{
  // nothing happens after setup
}

and that here:

#include <SD.h>
File myFile;
const int sdCard = 10;
long time1 = 0;
long time2 = 0;


void setup()
{
  Serial.begin(9600);
  pinMode(sdCard, OUTPUT);
  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. 
   
 
  if (!SD.begin(sdCard)) {
    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.
 
  
}

void loop() {
time1 = millis();

if (time1 - time2 > 1000&&time1 < 10000){
  myFile = SD.open("seconds.txt", FILE_WRITE); 
  Serial.println("time");
  Serial.println(time1);
  if(myFile){
  myFile.println("time");
  myFile.println(time1);
  }
  else {Serial.println("error opening secondse.txt");}
  time2=time1;  
  
  
  }
}

Thanks for your help!

Patrick