Memory problems with Serial.print

Hi..

Iam using arduino UNO with WiFLY shild.

Using Arduino 0022 and it tells me I got 32K byte maximum Flash mem.

From what I understand Boot loader takes 2K Flash

Soo my Sketch should then have around 30K of free memory?!

My sketch use 16K Flash

SRAM show 85 (using ATS_GetFreeMemory(); )

And my program behaves strange and restarts and crash
But if I remove all Serial.println("balbalb"); (debug lines)

I endup with having 600 of free SRAM and no crashes or strange restarts and everything works fine.

Soo my questions why dose Serial.println take up SRAM? when it should only take Flash ram (sketch ram)

Serial.println() does not take up space in SRAM. The literal strings you are printing do. Where else do you expect them to be stored?

Maybe a little bit reading will help:

Serial.println() does not take up space in SRAM. The literal strings you are printing do. Where else do you expect them to be stored?

I expected static text to be in flash. Would be awsome to be able to put static data in flash not needing to waste sram.

Would be awsome to be able to put static data in flash not needing to waste sram.

That's what PROGMEM is for.

expected static text to be in flash. Would be awsome to be able to put static data in flash not needing to waste sram.

In Arduino 1.0 this will be even simpler than "manual" PROGMEM stuff you can do now. In 1.0, you'll just do Serial.println(f("I'm in flash now"));.

That sounds great.

PROGMEM for me is to store long term data, not junk text for simple debugging.

I have 7.5Kbyte of static data I would like to dump into flash memory and then be able to search and extract data. (PROGMEM just 512? soo it's too small)

Is that possible ?

fableman:
PROGMEM for me is to store long term data, not junk text for simple debugging.

I think you misunderstand PROGMEM. Perhaps without realizing it, you have said "To me, text should be in RAM, not in Flash."

Which wouldn't make much sense would it? You have 2K of RAM and 32K of Flash. Why wouldn't you put all the "junk" in the space that is relatively large?

There are only three places to store any kind of data on an ATmega: Flash (aka "PROGMEM"), RAM, and EEPROM.

EEPROM is for storing non-volatile data.

RAM is for your program to work.

Flash / PROGMEM is Program Memory. It is where instructions are stored for execution. Wouldn't it make more sense to store constants associated with those instructions in the same place? Simple debugging messages are instructions with char array constants.

(PROGMEM just 512? soo it's too small)

On ATmega328:

Flash / PROGMEM: 32k
SRAM: 2k
EEPROM: 1k

The EEPROM isn't called Flash in this sense (even though that is what it is.) The EEPROM is meant for non-volatile storage by the running program. (e.g. storing calibration factors.)

Thanks PROGMEM will be my friend from now. :slight_smile: