Hi guys,
I have read quite a few helpful topics in the forum but couldn't find anything to my case. So here we go with my first post.
I'm preparing some functions for a bigger software and part of it is to write data to sd card.
The particular code:
boolean writeSD_byte () {
myFile = SD.open("byte.ini", FILE_WRITE);
if (myFile) {
Serial.print("...Writing...");
for (long i=0;i<1000000;i++) {
myFile.write(random(255));
}
myFile.close();
Serial.print("done...");
}
else Serial.print("failed...");
}
Running on an arduino mega with ethernet shield and an 32GB sd micro sd.
Failure description:
The for loop is currently set to 100000. If I further increase the number to 1 million or 10 million, I never get the serial print done message and the file has 0 byte size.
I haven't set any other outputs on purpose as I was simulating the fast writing which will be used in the program later.
I'm wondering whether there is:
- any cache which is used by the library which overflows
-any problem with the sd card size which maybe cause the problem (btw. I manually created a file of 10 MB and reading was no problem)
-any counter related to write() which reaches an invalid value
-any limitation on write() without closing the file in between
Thanks and regards,
Enrico