Problem with Arduino Uno and ATMEGA328

Hello

I have very strabge problem with my arduino uno and ATMEGA328. First a few words to say what I do. I use Arduino to control few devices over i2c protocol. Everything is fine, control is fine, hardware is fine but.... my source code is about 16k and stop working. After many days of debug I found that the problem is not in: - hardware - my devices - source code or anything else.

The only thing I noticed is that when my source code us under 11k everything work fine but when is over 11k arduino going crazy. Symptoms are: - unrecognized command - not read ot write via serial port - cannot print anything

Please if you have this problem help =(

r0adrunner: Hello

I have very strabge problem with my arduino uno and ATMEGA328. First a few words to say what I do. I use Arduino to control few devices over i2c protocol. Everything is fine, control is fine, hardware is fine but.... my source code is about 16k and stop working. After many days of debug I found that the problem is not in: - hardware - my devices - source code or anything else.

The only thing I noticed is that when my source code us under 11k everything work fine but when is over 11k arduino going crazy. Symptoms are: - unrecognized command - not read ot write via serial port - cannot print anything

Please if you have this problem help =(

Remember that a program is more than the source code. There is the resulting binary that is uploaded to the uprocessor, and there is also runtime behaviour. What you describe is similar to the odd behaviour you can get when a program hits the limit of SRAM at run-time.

So, the size of your source might correspond with some code that needs a lot of SRAM at runtime.

I'm also pretty sure that your RAM usage is too big.

You can move strings to the code area with: Serial.println(F("Hello World")); Do you have many arrays and buffers ?

r0adrunner:
The only thing I noticed is that when my source code us under 11k everything work fine but when is over 11k arduino going crazy. Symptoms are:

  • unrecognized command
  • not read ot write via serial port
  • cannot print anything

As others have mentioned, you are probably running out of RAM.

While you have 32k of PROGMEM, you only have 2K of RAM. Strings (like those used for Serial or LCD) consume that 2K of RAM.

Thnaks for help. I will try to move some strings and vars to EEPROM. I tell you what is result :)

r0adrunner: Thnaks for help. I will try to move some strings and vars to EEPROM. I tell you what is result :)

I think when you said EEPROM, you meant PROGMEM.

There are 3 memory spaces on the ATmega328: 1. PROGMEM: 32k. (Flash storage for program instructions). 2. SRAM: 2k. (Scratch pad volitile storage for running programs.) 3. EEPROM: 1k. (Flash/Non-volitile storage, read/write from running program.)

Starting IDE versions 1.0 or greater, you can store/retrieve strings (which are character constants) in PROGMEM using the F() macro.

Serial.println("Hello World");

can be changed into:

Serial.println(F("Hello World"));