ITDB32WD and SdFat.h

Hi!

Please, someone are using the SD card on TFT with the library SdFat.h?

I need only write a .TXT.

I think that haven't problem in my code because it works with the ITDB32S.

Anyway here's my code:

#include <SdFat.h>

const int chipSelect = 5;

Sd2Card card;
SdFile file;
SdFile root;
SdVolume volume;

float temp;
float tempe;

void setup()
{
  int16_t n;
  char buf[8];

  Serial.begin(9600);
  pinMode(53,OUTPUT);
  pinMode(69,OUTPUT);
  digitalWrite(53,HIGH);
  digitalWrite(69,HIGH);
  
  card.init(SPI_FULL_SPEED,chipSelect);
  volume.init(&card);
  root.openRoot(&volume);

  while(!Serial)
  {
    ; // wait for serial.
  }

  if(file.open(&root, "LOGTDIA.TXT", O_CREAT | O_APPEND | O_WRITE))
  {
    Serial.println("Writing...");
    Serial.println();

    for(temp=27.5; temp>22.0; temp-=0.15)
    {
      file.print(temp);
      file.write((uint8_t*)"\0", 1);
      file.write((uint8_t*)"\r\n", 2);
    }

    for(tempe=22.5; tempe<28.0; tempe+=0.15)
    {
      file.print(tempe);
      file.write((uint8_t*)"\0", 1);
      file.write((uint8_t*)"\r\n", 2);
    }
    file.close();
    Serial.println("Done!");
    Serial.println();
  }
  else
  {
    Serial.println("Can't open.");
  }

  if(file.open(&root, "LOGTDIA.TXT", O_READ))
  {
    Serial.println("Reading...");
    Serial.println();
    delay(5000);
    while ((n = file.read(buf, sizeof(buf))) > 0)
    {
      Serial.println(buf);
    }
    file.close();
    Serial.println();
    Serial.print("Finished!");
  }
}
void loop()
{
}

The ITDB32WD works fine using tinyFAT.h.

Here an image using tinyFAT.h:

Thanks in advance.

Fernando Garcia

      file.print(temp);
      file.write((uint8_t*)"\0", 1);
      file.write((uint8_t*)"\r\n", 2);

Trying to write the NULL is pointless. This code should be simply:

      file.println(temp);
Anyway here's my code:

Which does something. Are we supposed to guess what it does, as well as what the problem is?

Solved only changing on void setup():

card.init(SPI_FULL_SPEED, ChipSelect_SD);

To:

card.init(SPI_HALF_SPEED, ChipSelect_SD);

:smiley:

Thanks !

PaulS:
Which does something. Are we supposed to guess what it does, as well as what the problem is?

You are very rude !!!

You are very rude !!!

You are the one that bumbled in here demanding answers without providing any details. If you are offended by the questions, don't let the door hit you in the ass on the way out.