If I try to use the SD library in some of my bigger sketches, the SD.begin function restarts the Arduino. I have replicated the problem with a couple of long strings. Try opening the SD ReadWrite example sketch and adding the following two lines of code anywhere
String whatNow = "While the Arduino does have some on-board memory it's really not very much, only 1 kilobyte. If you're building something like an MP3 player, picture viewer or data logger you're going to need a lot more memory than 1 kilobyte. A microSD card is really just memory that you can read and write to; even better is that with Arduino you can implement a file system, like FAT16 or FAT32, which lets you easily create, read and write to files. microSD cards are available with memory sizes of 256 MB all the way up to 32 GB and higher! You can pick any size card you'd like to suit you application without modifying the sketch. If you want to start digging around with some example sketches here's a good starting point:";
String ahhh = "In order to write information to a microSD card we need to have access to a file. If a file doesn't exist yet it must be created. Before the file can be created, though, we must initialize the microSD card to use a FAT file system, initialize a volume on the file system, and then finally open the root directory in the volume. Once all of this is done we can create a file. Luckily for us, the SdFat library (written by William Greiman) does most of the work for us! First create the objects that are needed for the FAT library to work. This code must go at the start of the sketch before both the loop and the setup sections:";
If you run the sketch now, you should see the arduino go into an infinite loop. It will print "Initializing SD card..." to serial each time it restarts.
I can stop this from happening by commenting out line 370 in Sd2Card.cpp in the SD Library. Of course, this breaks the SD functionality but it stops the arduino from resetting.
// transfer data
n = count - 1;
for (uint16_t i = 0; i < n; i++) {
while (!(SPSR & (1 << SPIF)));
// dst[i] = SPDR;
SPDR = 0XFF;
}
Can any reproduce this? Any insight into why it's happening?