Odd behaviour and corruption at 8584 bytes?

Hello,

So, I was happily programming away with my Arduino Decimila, building a sketch that interfaces with a RTC chip using the Wire library, when all of a sudden my entire program stops working. I check to make sure that I didn't screw something up, but everything's fine.

Anyway, 2 hours of troubleshooting later, I discover that if my sketch is bigger than 8584 bytes, it screws up, with odd problems ranging from: - Failure to start entirely - Weird non-printable characters or other crap on the Serial console output - Wire interface no longer functioning.

Removing ANY code (including text from a string) to bring the compiled size down below 8584 causes the program to work again, exactly as expected.

Binary sketch size: 8582 bytes (of a 14336 byte maximum)

This is the last size at which the program still runs.

  • I'm using arduino 0010, I just downloaded a new one to be sure
  • I'm using only the Wire interface
  • I have set my "board" to the "Decimilia" and do have the correct chip selected.

Could it be: - Hardware problem with my Arduino? - Problem with my USB port? - Bug in Arduino compiler?

I will post my sketch if you require it. Thanks.

P.S. These sketch sizes are how I found the problem: 8364 - ok. 8538 - ok. 8552 - ok. 8564 - ok. 8574 - ok. 8582 - ok. 8584 - bad. 8588 - bad. 8758 - bad.

P.S. 2 I just tried making a 13398 byte sketch by putting in tons of useless strings, and it just gave me gibberish ascii characters on the console.

P.S. 3 I just put the software and the board on a totally different computer with the latest drivers and software, and tried uploading the same sketch, and it did exactly the same thing.

You're probably running out of RAM. The ATmega168 only has 1 KB, and I don't know of any way to measure the usage (in general, you can't, but we could try to guess). If you have a lot of constant strings, you might try putting them into the program memory. See this page on PROGMEM.

Sigh. Yes. This was the problem.

Thanks. :)