Hello Arduino-Gurus,
short version: If I put a value in Flash using PROGMEM, does this require space in SRAM as well, e.g., for a pointer to the memory address in Flash?
long version:
I have written a sketch that is running out of SRAM, therefore I need to cut down on data stored in SRAM. I have several values that are currently defined as variables but actually have a fixed value that is known at development time.
I am now thinking about moving these values to Flash using PROGMEM. However, I am not sure whether I will actually save anything as I am dealing with a bunch of uint16_t here.
Looking at this problem globally, I would expect that since when I use PROGMEM, everything is known at compile time, the calls to copy data from the PROGMEM'd variable into SRAM for processing would amount to a bunch of MOV (or LOAD or whatever the AVR equivalent is) instructions with a fixed operand address, which also end up in Flash, i.e., zero SRAM usage. However, a number of websites that (vaguely!) discuss PROGMEM indicate that a pointer, stored in SRAM, is involved. For strings this clearly saves memory, I'm just wondering whether I'll replace one memory word containing the value by another memory word containing a pointer to the variable and thus making matters worse.
Regards,
deltaphi