I've been learning various functions here and I've gotten them to work in individual sketches for individual functions:
I learned how to connect my EthernetShield and my EthernetPOE to the network with a fixed IP address and connect to the Internet. I learned how to do the same with my WiFi shield but with DHCP as Fixed IP doesn't work on the WiFi shield (a separate matter). I created an individual sketch for each of these functions (3 sketches) and they worked fine.
I learned how to access the SD card, create and write to files on the SD card, set the datetime stamps (created, modified & accessed) on the files with set values, read the files' sizes and read the amount of free space on the SD card. I put all of this in to one sketch and it worked fine.
I learned how to get the time from a fixed NTP server, adjust it for a given time zone (mine), store it in a time variable and display the various time elements properly formatted. I put all of this in to one sketch and it worked fine.
Then I got ambitious ... and it seems to have fallen apart.
I put all of these functions in to one big sketch as it is part of a long-term goal for an actually functional project... It compiles fine although it is much bigger than I thought it would be at this stage (25,516 byte). But I certainly haven't even started optimising any of it... I'm just trying to get it to run.
When it runs it gets to the part where it sets the IP address on the card and display the address info. As it displays the DNS it only displays the first digit of the address, then one random character and ... the whole sketch starts up again ... and again ... and again ...
[The code's too big to put in this message I'm going to try putting it in a separate message]
I couldn't get the code to fit in one message here. So I am trying to upload it Github...
Here it is:
As it restarts within Setup() and every function appears to execute fine without returning any errors I don't even know where to start debugging this thing...
Which Arduino are you running this on? The 328-based Arduinos have 2K of SRAM. The SD library needs 1/4 of that for the buffer to read from/write to the SD card.
You have a LOT of literal text strings that are being copied from program memory to SRAM at run time. You can use the F() macro to stop that from happening:
Serial.println(F("DEFAULT.TXT created with default date/time stamps:"));
Which Arduino are you running this on? The 328-based Arduinos have 2K of SRAM. The SD library needs 1/4 of that for the buffer to read from/write to the SD card.
I should have said that up front. This is running on the Arduino Uno with the Ethernet Shield.
I also will be testing it on an ArduinoPOE and then on an Arduino Uno with a WiFi Shield.
I understand the memory management problems of storing tons of literals in to SRAM at run time. I had not (yet) seen any mention of F() macros in the examples I've been reading. I will certainly try that...
Aside from the code being less elegant and hogging memory do you think that is actually part of the execution problem?