Loading...
Pages: [1]   Go Down
Author Topic: constant variables  (Read 223 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
Offline Offline
Brattain Member
*****
Karma: 311
Posts: 35478
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: 279
Posts: 15314
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
Online Online
Edison Member
*
Karma: 43
Posts: 2494
"We're a proud service of the Lost Electricity Reclamation Agency"
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Get the infamous "One Million Ohms" board at tINDIE.com: http://tinyurl.com/BuyMohms

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 137
Posts: 19024
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.

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: 137
Posts: 19024
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.

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
Print
 
Jump to: