Go Down

Topic: constant variables (Read 642 times) previous topic - next topic

a variable "int" will be storage in SRAM memory. right?
a "const int" will be storage in SRAM memory or in flash memory?
how can i do for storage an array in a FLASH memory? only with PROGMEM?
my array is char img(5000);

tuxduino

Have you tried searching for PROGMEM on this site ?

http://www.arduino.cc/en/Reference/PROGMEM

PaulS

Quote
how can i do for storage an array in a FLASH memory? only with PROGMEM?

Yes. Keep in mind that Flash memory is read-only.

What are you doing with 5000 bytes of image data?

retrolefty


a variable "int" will be storage in SRAM memory. right?
Correct
a "const int" will be storage in SRAM memory or in flash memory?
SRAM
how can i do for storage an array in a FLASH memory? only with PROGMEM?
Correct, and you will need to use specific commands to read them back in your sketch from flash.
my array is char img(5000);

http://arduino.cc/en/Reference/PROGMEM
Lefty



Jack Christensen

Is "const int" likely to be optimized out of SRAM by the compiler?
MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

AWOL

Quote
Is "const int" likely to be optimized out of SRAM by the compiler?

Depends very much how it is used.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

tuxduino


Quote
Is "const int" likely to be optimized out of SRAM by the compiler?

Depends very much how it is used.


Hmmm... after all it's just a typed #define. IOW, a literal...
* tuxduino thinks...

AWOL

Quote
Hmmm... after all it's just a typed #define. IOW, a literal.
Ever tried taking the address of a #define?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

tuxduino


Quote
Hmmm... after all it's just a typed #define. IOW, a literal.
Ever tried taking the address of a #define?

Well, I know a const is _not_ a typed #define. I was just saying a const can be viewed as a literal.

Taking the address of a const variable is probably one of the things that prevents the compiler from optimizing them out...

Go Up