Variable "File"???

Hello wath kind of Variable is “File” of the SD lib. And how big it can go. I think if have an overwrite Prob.
Pip

Hello wath kind of Variable is "File" of the SD lib.

Is this a trick question? That is a type.

And how big it can go.

37 centimeters by 50 parsecs by 12 lightyears.

Or maybe not. Perhaps I don't understand what you mean by "how big" it can go.

Big means number of bytes. I think I have an overwrite Prob.

I think I have an overwrite Prob.

I think you need to post some code, and explain what you think is being overwritten by what.

SD.

Request:

  if (avs == 0x0F && digitalRead(7) == 1)
  {
      LOG_DATA(&log_str[0], lls);
      for (byte i = 0; i < lls; i++) log_str[i] = 0x00;
      avs = 0;
  }

SD Write:

#include <SD.h>

File myFile;

void LOG_DATA(char* p_data, byte lls)
{
  myFile = SD.open("log.csv", FILE_WRITE);
  
  if (myFile)
  {
    Serial.print("Writing to log.csv...");
    for (byte i = 0; i < lls; i++)
    {
      myFile.print(&p_data);
    }
    myFile.print(&p_data);
    myFile.close();
    Serial.println("done.");
  }
  else
  {
    Serial.println("error opening log.csv");
    return;
  }
  
  myFile = SD.open("log.csv");
  if (myFile)
  {
    Serial.println("log.csv:");
    double i = 0;
    while (myFile.available())
    {
      Serial.write(myFile.read());
      File_Size++;
    }
    Serial.print("Bytes of File = ");
    Serial.println(File_Size);
    myFile.close();
  } 
  else
  {
    Serial.println("error opening log.csv");
    return;
  }
}

This Part dosnt working.

myFile = SD.open("log.csv", FILE_WRITE);
if (myFile).....

Wile im Writing on the SD Card, are running some I2C interrupts, could it bee that these interrupts are the problem???

Wile im Writing on the SD Card, are running some I2C interrupts, could it bee that these interrupts are the problem???

Apparently, there was something about "Post ALL of your code" that you think doesn't apply to you. It does.

I did a new try. With the same overwrite Result. This time not even the the initial of the SD is running proper. And my Computer understands my SD Card not until i reboot.
slave Main runs on Arduino Uno

#include <Wire.h>
#include <SD.h>

File myFile;
unsigned long File_Size;
unsigned long SD_size;

Sd2Card card;
SdVolume volume;

#define ADDRESS 42
#define str_lenght 51

volatile char buf [68];
volatile byte pos = 0;

void TWI_dis()
{
  TWCR |= (1<<TWSTO);
  TWCR &= ~(1<<TWEN | 1<<TWIE);
}

void TWI_en()
{
  TWCR |= (1<<TWEN | 1<<TWIE);  
}

void setup () 
{
  Serial.begin (56000);
  SD_init();
  delay(1000);
  Wire.begin (ADDRESS);
  Wire.onReceive (receiveEvent);
}  // end of setup

void loop() 
{
  // display when filled up
  if (pos >= str_lenght)
  {
  for (int i = 0; i < str_lenght; i++)
    Serial.print(buf[i]);
    Serial.println();
  pos = 0;
  }  // end if
}  // end loop


void receiveEvent (int howMany)
 {
  while (Wire.available () > 0)
  {
   byte c = Wire.read();
   if (pos < sizeof buf)
     buf [pos++] = c;  
  }  // end while available
  
}  // end of receiveEvent

slave SUB

void SD_init()
{
  Serial.print("\nInitializing SD card...");
  pinMode(10, OUTPUT);

  SD_size_check();
  
  Serial.print("Initializing SD card...");
  if (!SD.begin(10)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
  
  if (SD.exists("LOG.CSV")) {
    Serial.println("LOG.CSV exists.");
  }
  else {
    Serial.println("LOG.CSV doesn't exist.");
    // open a new file and immediately close it:
    Serial.println("Creating LOG.CSV...");
    myFile = SD.open("LOG.CSV", FILE_WRITE);
    myFile.close();
  }
}

void SD_size_check()
{
  if (!card.init(SPI_HALF_SPEED, 10)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card is inserted?");
    Serial.println("* Is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    return;
  } else {
   Serial.println("Wiring is correct and a card is present."); 
  }

  Serial.print("\nCard type: ");
  switch(card.type()) {
    case SD_CARD_TYPE_SD1:
      Serial.println("SD1");
      break;
    case SD_CARD_TYPE_SD2:
      Serial.println("SD2");
      break;
    case SD_CARD_TYPE_SDHC:
      Serial.println("SDHC");
      break;
    default:
      Serial.println("Unknown");
  }

  if (!volume.init(card)) {
    Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
    return;
  }

  uint32_t volumesize;
  Serial.print("\nVolume type is FAT");
  Serial.println(volume.fatType(), DEC);
  Serial.println();
  
  volumesize  = volume.blocksPerCluster();
  volumesize *= volume.clusterCount();
  volumesize *= 512;
  SD_size = volumesize;

  Serial.print("Volume size (bytes): ");
  Serial.println(volumesize);
}

master Main runns on a Arduino MEGA ADK

#include <Wire.h>
#include <TimerOne.h>
#define ADDRESS 42

// Time Date arrays
//                  d  m  y  h  m  s
byte TimeDate[6] = {0, 0, 0, 0, 0, 0};
char Time[8];
char Date[8];

// Peripherial Arrays
char defice_temp[2][16] = {{"Temperatur"},{"24"}};

void setup () 
{
  // Timer1 init
  Timer1.initialize(1000000);
  Timer1.attachInterrupt( timerIsr ); // attach the service routine here  

  // Wire init  
  Wire.begin ();
}  // end of setup

void loop () 
{
  Wire.beginTransmission (ADDRESS);
  for(int i; i < 8; i++)   Wire.write(Date[i]);
  Wire.write(';');
  for(int i; i < 8; i++)   Wire.write(Time[i]);
  Wire.write(';');
  for (int i; i < 16; i++) Wire.write(defice_temp[0][i]);
  Wire.write(';');
  for (int i; i < 16; i++) Wire.write(defice_temp[1][i]);
  Wire.endTransmission ();
    
   delay (2000);
}  // end of loop

void timerIsr()
{
  TimeDate[5]++;
  T_eval();
}

Master SUB

void TD_to_char()
{
    const int bc = 48;
    int c = 0;
    int i = 0;
    do{
    Date[i++] = (TimeDate[c]/10)+bc;
    Date[i++] = (TimeDate[c++]%10)+bc;
    if (i < 7) Date[i++] = '/';
    }while(c < 3);

    i = 0;
    do{
    Time[i++] = (TimeDate[c]/10)+bc;
    Time[i++] = (TimeDate[c++]%10)+bc;
    if (i < 8) Time[i++] = ':';
    }while(c < 6);
}

void T_eval()
{
  if (TimeDate[5] > 59)
  {
    TimeDate[5] = 0;
    TimeDate[4]++;
    if (TimeDate[4] > 59)
    {
      TimeDate[4] = 0;
      TimeDate[3]++;
      if (TimeDate[3] > 23)
      {
        TimeDate[3] = 0;
        TimeDate[0]++;
        
        if ( ( TimeDate[1] == 4 || TimeDate[1] == 6 ||  TimeDate[1] == 9 || TimeDate[1] == 11 ) && TimeDate[0] > 30 )
        {
            TimeDate[0] = 1;
            TimeDate[1] ++;          
        }
        else if ( ( TimeDate[1] == 1 || TimeDate[1] == 3 ||  TimeDate[1] == 5 || TimeDate[1] == 7 || TimeDate[1] == 8 ||  TimeDate[1] == 10 || TimeDate[1] == 12 ) && TimeDate[0] > 31 )
        {
            TimeDate[0] = 1;
            TimeDate[1] ++;            
        }
        else if ( TimeDate[2]%4 != 0 && TimeDate[0] > 28 )
        {
            TimeDate[0] = 1;
            TimeDate[1] ++;
        }
        else if ( TimeDate[2]%4 == 0 && TimeDate[0] > 29 )
        {
            TimeDate[0] = 1;
            TimeDate[1] ++;
        }
        if ( TimeDate[1] > 12)
        {
          TimeDate[1] = 1;
          TimeDate[2]++;
          if (TimeDate[2] > 99) TimeDate[2] = 0;
        }
      }
    }
  }
  TD_to_char();
}

To have a larger TWI Variable I changed
#define TWI_BUFFER_LENGTH 64
in twi.h
and
#define BUFFER_LENGTH 64
in Wire.h

the Result is something like this

Grummel :~

plzplz PaulS Panter a little hint about the background routines would be just perfect. I’f also checked if there is a RAM overflow, avr-objdump and avr-size. But all is in the green Zone. So I THINK while the TWI and SD lib wirte both on the EEprom an they overwrite each other. It will allso help if there is a method to kill all TWI variables from the SRAM. Means wire.end().