1

I'm declaring an array at top level like so:

constexpr byte a[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; // whatever data

I'm referencing the array in such a way that it's not optimized away. When compiling this from the Arduino IDE it informs me that it's using 1474 bytes of program storage space and 194 of dynamic memory. Curiously enough if my array is twice the size (20 elements) there are 10 more bytes of both program storage and dynamic memory used (1484 and 204 respectively).

Can I convince the compiler somehow to store all this in program storage space only? Any qualifiers or options I should be using instead? (and why would it take up space in both memory spaces anyway?!)

I'm using an arduino uno.

3
  • 1
    You have to use PROGMEM or newer AVRs like Atmega4809 with "flat" memory model (all different types of memories are mapped into the same memory space and accessible by the same pointers) Commented May 7, 2021 at 16:34
  • arduino.cc/reference/en/language/variables/utilities/progmem Commented May 8, 2021 at 6:09
  • 1
    These feel like answers more than comments so if you think the same post it as such so I can accept it; progmem is not seamless but it does the job Commented May 16, 2021 at 20:05

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.