I'm running simple loops using the Teensyduino iterating a variable (x) from 1 to, say, 10,000. It's a scaled down problem in an attempt to find a solution for a bug in a much larger code. The problem is that after writing a certain number of lines to the SD, it will stop writing for a certain quantity of values, then start back up again, e.g. In the most recent trial it recorded from 1 - 4293, then stopped, and began on the next line (Excel line 4294) with 14581, then continued until I cut it off around 15350.
Also, the odd time it will print two values on the same line instead of skipping to the next one.
I've been running the trials alongside Serial port recordings using the PuTTY program (very useful program) which creates a .txt or .csv file with the serial port output.
It's confusing, as in both the larger code and this simple one, the serial outputs are always exactly what is desired, and it's not a fault with the SD card as I've tried using a few different ones and the same problem emerges.
I'm thinking it might be a problem with opening and closing the datafile so often and quickly (would anyone have a better way of doing this?), or else maybe with the SD library.
Has anyone else had a similar problem?
Here's the code:
Purpose of this program is to check for faults with writing to the SD card.
const int chipSelect = 5;
long int x = 0;
Serial.println("SD card initialized.");
x = x + 1;
File dataFile = SD.open("datalog.csv", FILE_WRITE);
Serial.println("error opening datalog.csv");
while (Serial.available() <= 0)
Any help would be greatly appreciated!