Help needed with debug strategy

I am working on a multi-function clock project with 6 Rainbowduino modules, a RTC module and an Ethernet shield. The Ethernet client used the NTP protocol to correct the RTC module and the time, date and so on scroll across the LED panels.

I have developed these pieces separately over the last couple of months and each piece works great alone. When I put them together (Ethernet and I2C) I start to get runtime problems. I2C is used to talk to the DS1307 RTC and do the LED panels. When I added in Ethernet functions I started getting errors in the I2C processing. After looking at the I2C code for a long time I started to look at narrowing down the Ethernet code.

In the summary code below you can see the basic flow (the CallNTP function is exactly what is in the sketch). If I comment out the call to “CallNTP” then it works. If I leave it in, I get failures (bad data on I2C reads). It's a matter of just having the code there since the failure occurs before it is even called. The declaration at global scope can be there without an ill effect.

Client client(server, 37);

loop() { GetTheTime(); // Query RTC ShowTheTime(); // Display time on LED panels CallNTP(); // Call out to the NTP server }

CallNTP() { client.connect(); client.stop();

return; }

The sketch is about 700 lines so far and without the call to “CallNTP” it's 10190 of 14336 bytes. With the call in it increases to 12604 bytes since it needs the Ethernet library. I am using Arduino 0017.

Are there any interactions between Ethernet and Wire that I may have missed? I thought this worked fine back when the overall sketch was much smaller. Are there size issues or memory layout issues that I should be looking at... and if so how?

Any suggestions would be great. Thanks!

Ken

First thing that springs to mind is "How much RAM are you using?"

How can I tell?

I do not use malloc and I don't have much defined at global scope (~100 bytes). Except for debug statements I don't have many strings.

I am happy to share the code although it won't run without all the peripherals I have attached.

Ken

I don't have much defined at global scope

You don't, but what about the libraries? Stack?

Have a look around the playground and forum for RAM useage-reporting functions.