Go Down

Topic: [SOLVED for Maple Mini Stm32duino] How to access PROGMEM array dynamically (Read 135 times) previous topic - next topic

Flub

[EDIT: I just found out the solution for the maple mini I use in my project. I just had to write this instead
Code: [Select]
uint16_t gammaTable[94] [256] __FLASH__ = {...}; then i could just access it as it would be stored in ram... ]
Hey there,
I ve got a problem I could sadly not solve yet...
I want to store a big one dimensional array of uint16_t values and access it dynamically from a function.

This is how i create it
Code: [Select]
const uint16_t gammaTable[] PROGMEM = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,3,3,3,3,4,4,5,5,5,6,6,7,8,8,9,10,10,11,12,13,14,15,16,18,19,
...
0, 15200, 0,0};


Now the problem is that i cannot not get a specific value dynamically with a variable as array index or so. I can get the variable with a static number as index like this:
Code: [Select]

Serial.println(pgm_read_word(&gammaTable[93]));


But if i want to access it like this it does not work any more.
Code: [Select]

void displayFrame() {
  for (int i = 0; i < 192; i++) {
    uint16_t result = pgm_read_word(&gammaTable[i]);
    Serial.println(result);
  }
}


I dont know what i can do to read it that way. Does any know it?
best,
Flub


Go Up