Bug with ATMEGA168 memory

Hi, I have a Boarduino with AMTEGA168 chip, and when I upload a program that is greater than half of the flash memory (near of 8000 bytes...), the microcontroller bugs, and sometimes it self-resets. my program have a lot of "Serial.print" and I see only meaningless characters on serial monitor.
Someone have any idea of thats wrong? Apparently Arduino are crashes RAM...

greater than half of the flash memory (near of 8000 bytes...),

Remember while a 168 may have 16k of flash it has only 1k of SRAM that holds all your variables, arrays, strings, stack space, etc. So it is quite possible that your sketch is going buggy because it's running out of SRAM. Possibly if you post your sketch some of the software gurus around can see what is what.

Lefty

Really, my sketch have about 1500 lines, and is probably that it's running out of SRAM...

Maybe if I use the function "PROGMEM" to allocate my variables in flash memory, the program runs ok. Will look this up a little more, thanks.

That can certainly help. Also a cheap upgrade is to swap in a 328 chip that will double both flash and SRAM size.

Lefty

Really, I use the library "pgmspace" to alocate the strings in Flash memory with the function "PROGMEM" and it finish with my problem :slight_smile:
The syntax of the sketch was more confuse, but now I don't have problem with RAM.
Thanks.