sketch size problem

I'm working on "Arduino Uno" and I'm developping a quite complex sketch.
All work fine if the size of the sketch is less than 14000bytes (32256 is the maximum avalaible)
If I put some extra code and the sketch becames more then 14000bytes, Arduino board stop to work.
I put just more simple code (I just duplicate same functions). I'm sure there are not errors in this extra code.
Does someone developped a sketch more than 14000bytes?
Could be possible there exist a Flash Memory fault in the ATMega328?
How can Debug this issue?
I have tried with "Arduino.exe" IDE 0.22 and IDE 1.00 with the same result.

Does some one give me some helps?

My largest sketch is 28046 bytes and it works as expected.

There could be a FLASH faultin your Arduino but I would expect that so show up as a Verify error on uploading.

Most likely it is a programming error, even if you think that all of your 'quite complex sketch' is completely correct. Even expert programmers have been known to make mistakes.

I've had that problem too. You are probably exceeding the amount of SRAM. The IDE only shows you the size of the program memory used by the sketch - it does not show its SRAM requirement. This can usually be solved by moving a lot of your strings into PROGMEM.

Pete
[edit] This thread should be in Programming Questions

You are on right about SRAM. I did some tests by reducing the number of strings. Now the sketch works.
I need to use a lot of strings in my sketch. How can I move them in the PROGMEM?
Could you send me any samples to show, or describe, how to put strings on PROGMEM?

If you have something like this:

  Serial.print("Something really useful");

You first have to include the header:

#include <avr/pgmspace.h>

Then change the print statement (and others like it) to:

  P_serial_print(PSTR("Something really useful"));

and add this function to your sketch:

// PROGMEM string printer
void P_serial_print(const char *s)
{
  unsigned char c;
  while(c = pgm_read_byte(s++)) {
    Serial.write(&c,1);
  }
}

See this webpage for more info: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=38003

Pete

I've just found an easier way to do it.
Change any statement of this form:

  Serial.print("Something really useful");

to this:

  Serial.print(F("Something really useful"));

Pete

Hi Pete,

your information are very useful. I took a look to the AVR article you wrote.
I understand your descriptions about "PSTR" define and "pgm_read_byte" function.
I have not found information about "F" define and how it works. Where did you find this information?
Could you explain more?

Thanks a lot
Mrk

I took a look to the AVR article you wrote.

I didn't write it. I just linked to it as the source of my info on PROGMEM.

about "F" define and how it works. Where did you find this information?

It's actually in the documentation of Serial.print here:

But it is one sentence (plus an example) and is easy to miss!

Could you explain more?

There isn't much difference between using PSTR() and F(). In fact, If you use F(), the preprocessor changes it to PSTR anyway. But it adds a little bit more too which allows the compiler to use the version of Serial.print which handles PROGMEM strings. Using F() means you don't have to add your own function which prints progmem strings.

Pete