Pages: [1]   Go Down
Author Topic: constant variables  (Read 476 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you tried searching for PROGMEM on this site ?

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

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46140
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16523
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 71
Posts: 3516
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 239
Posts: 24371
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is "const int" likely to be optimized out of SRAM by the compiler?
Depends very much how it is used.
Logged

"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.

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 239
Posts: 24371
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"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.

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

Pages: [1]   Go Up
Jump to: