7
votes
How can a function/method determine if a const array passed in is PROGMEM (flash) or not (RAM)?
I am afraid there is no good solution to this problem. One option I do
like is to use the __flash qualifier instead of PROGMEM:
const uint8_t ram_array[] = { 1, 2, 3, 4 };
__flash const uint8_t ...
6
votes
Accepted
PROGMEM : pgm_read_float_near() equivalent for double? (Arduino Due)
Arduino Due (ARM Cortex-M3) doesn't need anything like PROGMEM as it has access into the flash memory in the same way as into the RAM. The const qualifier is enough to keep it in program memory only.
...
5
votes
Accepted
How to correctly pack an unsigned long from 3 unsigned chars?
You can try (explict unsigned long values):
unsigned long fromValues = (0x00UL << 16) | (0x01 << 8) | 0xF3;
Serial.println(fromValues);
or:
value = (((unsigned long) c1) << 16) | ...
5
votes
Accepted
PROGMEM doesn't cause Sketch size to change
all constant data are part of the sketch. where else should they be? in runtime they are loaded into RAM. PROGMEM directive prevents the loading into RAM.
4
votes
Accepted
Read nested array item from PROGMEM
The library, as it stands, doesn't support direct sending from PROGMEM. However it's not too hard to get around that - if your C++ is up to it.
The IRsendRaw class is a child class that extends the ...
4
votes
How can a function/method determine if a const array passed in is PROGMEM (flash) or not (RAM)?
There is also an OO solution possible, using the strategy design pattern, but this comes with some (slight) memory and performance penalties. You need to use C++ for this.
Put each array you want to ...
4
votes
Accepted
PlatformIO and const PROGMEM
The PROGMEM qualifier can only be applied to statically-allocated
constant data. When you move the decimalDigit array inside the class,
it becomes a data member, i.e. you have one copy of the array ...
4
votes
Accepted
Large arrays crash the arduino
In the edited version of your question, you wrote:
I am using memcpy_P() in order to copy the arrays from PROGMEM to
RAM.
The whole purpose of PROGMEM is to avoid having to store the data in
RAM. If ...
3
votes
Accepted
Arduino IDE: How to get PROGMEM const length?
Probably the best way would be to define below it
const int eye_len = sizeof(eye)/sizeof(eye[0]);
If the linker does link time optimization, or if you only use it within the same file (and declare ...
3
votes
ATmega328, arduino nano v3 code error saying insufficient ram memory
The font definition table takes 960 bytes of RAM - nearly 1/2 of the the total usage. You can regain 480 bytes just by declaring that array as uint8_t; 1 byte each entry instead of 2 bytes each for ...
3
votes
Accepted
Problem when using PROGMEM on array holding notes for speaker on Arduino
You can not directly dereference something ("access an array") that is in flash memory. You have to use pgm_read_xxx functions from <avr/pgmspace.h> .
In your case you should probably write ...
3
votes
Accepted
Is there a way to "list" (in BASIC, or "cat" in LINUX) the current sketch loaded in my xxxDUINO?
No. the code burned in an Arduino is compiled not interpreted like Basic.
Basically your C language sketch is compiled into AVR assembly language. The resulting hexadecimal is what is burned to the ...
3
votes
Accepted
How is a 41KB char array filling up 256KB of program memory?
The limitation here is the data type of the index of the array. That is int, and on an 8-bit system an int can hold a value in the range -32768 to 32767.
That means the biggest index number an array ...
3
votes
Inherent delay running EEPROM.read()
When I store it in the EEPROM, the extra time required to find it in EEPROM, pull it through the sketch, and then push it through to the db corrupts the data sourced from EEPROM and posts a jumbled ...
3
votes
Initialize object with PROGMEM constants
const char* text; is a pointer to constant not a constant pointer (char * const text is a constant pointer). So you can assign a pointer to a constant char array to const char* text; even a pointer to ...
2
votes
Possible to "inline" PROGMEM strings into a structure array initialization?
If the strings are similar size you can, like this:
const int NUMBER_OF_ELEMENTS = 10;
typedef struct {
char description [12];
} descriptionType;
const descriptionType descriptions [...
2
votes
Accepted
Using PROGMEM in constructor
The closest I could get to what you are trying to do is this:
template <size_t table_size> struct Ex_class {
int get_value(int index) const {
return pgm_read_word(&_ex_table[index]);
...
2
votes
Accepted
Reading a 10-byte buffer out of a PROGMEM string stored in a string table
The first thing you need to fix is this:
/home/nick/Arduino/Large_Progmem_test/Large_Progmem_test.ino: In function 'foo()':
/home/nick/Arduino/Large_Progmem_test/Large_Progmem_test.ino:42:27: warning:...
2
votes
Accepted
Possible to determine at runtime whether a pointer is declared PROGMEM?
Not really, if you are asking whether you can determine (simply from its value) whether 0x100 is in RAM or PROGMEM. Both are possible candidates for a memory location.
The F() macro works around this ...
2
votes
Saving byte array in PROGMEM instead of SRAM
See Putting constant data into program memory (PROGMEM) for tips about putting stuff into PROGMEM. However personally I wouldn't get too excited about saving 6 bytes.
Example code:
Declare data ...
2
votes
How to correctly pack an unsigned long from 3 unsigned chars?
I got it to work by typecasting firmly and using multiplications:
Serial.println("data using counter:");
for (int i = 0 ; i < 10; i++) {
c1 = onsets1[i];
c2 = onsets2[i];
c3 = ...
2
votes
PCM audio, PROGMEM sounds through speaker, multiple clips (using speaker_pcm)
I think it's just a case of startPlayback() being asynchronous. It doesn't block; it doesn't wait for playback to finish. It just sets up the 8000 Hz timer interrupt and returns.
The original code ...
2
votes
PROGMEM on Arduino Due (ARM Cortex M3)
There is no PROGMEM required on ARM. There is no memory bus separation between Flash and RAM, so it doesn't copy constants from flash to RAM which PROGMEM is used to prevent.
2
votes
PROGMEM Corrupted Array
Just a follow up in case someone else has the same problem. One solution is Nick's answer in his comment, which grabs the far addresses first in the setup, storing them in an array, and using them. I
...
2
votes
Accepted
Initialize and read from a PROGMEM array of pointers to PROGMEM arrays
const byte* const message[] PROGMEM =
to use an item, load it in RAM
strcpy_P(buffer, (byte*)pgm_read_word(&(message[i])));
source Arduino reference - PROGMEM
2
votes
Printing elements of char array from PROGMEM
Among many others, check out pgmspace.h utilities at
AVR-libc
2
votes
Accepted
Use of progmem in ESP8266 vs AVR and also how to handle large dynamic strings
On the ESP8266 flash is a very special case. Because the ESP8266 itself does not have any flash, but instead uses an external SPI-connected flash chip, accessing it is not an easy or technically ...
2
votes
Accepted
Initialize object with PROGMEM constants
It is a shame that gcc only supports the __flash qualifier in C mode,
not in C++, so we have to use PROGMEM instead. Unlike __flash, which
qualifies a variable just like const, the PROGMEM attribute ...
2
votes
Accepted
How to create large progmem arrays and not annoy the linker
Include Guards only protect against inclusion of a header file multiple times within the same translation unit. This is important. If you include a header file (1) in a source file, then include ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
progmem × 64arduino-uno × 9
flash × 9
memory × 9
c++ × 7
memory-usage × 7
array × 6
programming × 5
sram × 5
arduino-ide × 4
avr × 4
serial × 3
esp8266 × 3
arduino-nano × 3
atmega328 × 3
struct × 3
arduino-mega × 2
arduino-due × 2
string × 2
arduino-pro-mini × 2
pointer × 2
sketch-size × 2
constants × 2
sam3x × 2
led × 1