Strange behaviour with EEPROM

Hello.

I'm writing a program by using arduino 1.0.6 for a board with the ATmega32U4. The program is using around 24K of the 28K available (at least this is what the IDE is saying). I'm using also the EEPROM to store some configurations.

I'm facing this strange behavior:

it looks like that when I add a single instruction like

Serial.println("write something"); delay(1000);

the sketch stops working. When I comment this out, it starts to work again. In the debug activity it looks like that when I add this instruction, a part of the EEPROM becomes corrupted (so I see data I don't expect). Is this possible? Or I'm doing something wrong with the debugging? May be I have a memory leak somewhere?

Thanks a lot!

Research using the F() macro.

(This is the Programming section - it's kinda expected you post code here)

Hello.

Thanks a lot. Sorry if may be I posted in the wrong section. I didn't posted the code because the whole program is quite long and complicated and I don't expect that someone will review it.

I searched for F() macro, thanks!

cecio

Hello. One question: but if use F() macro, I can avoid to overwrite the data I'm storing manually in the EEPROM? Thanks,

The EEPROM shouldn't become corrupt unless you're unintentionally writing bad data to it or resetting in the middle of a write.

The F() macro used elsewhere (unrelated to the EEPROM) can reduce your memory use (RAM) which may become corrupt if you start using more than exists.

so I see data I don't expect

Are you sure the EEPROM has bad data, as it may just be your working copy in RAM.

mmm....I'm checking....but I think you could be right about the copy in RAM....

The original error is almost certainly due to running out of SRAM. The Arduino will lock up or do strange things, even when you just add a simple Serial.print("hello"); because those 5 chars in the string fill up the SRAM and overwrite something else totally unrelated.

The EEPROM is not affected and it's not the cause of this problem.

See http://www.gammon.com.au/progmem