I have a number of arrays all of different sizes that I have stored in flash memory. I can access single array entries with
byte j = pgm_read_byte(&(array[x]));
What I want to do is to pass the array from the flash memory as an argument to a function. I have tried giving a pointer to the array, as an argument but this gives a compilation error:
void callPGM2(byte arr_size, byte *arr) {
..
..
}
ptr2 = &pgm_read_byte(&(array_1[0]));
callPGM2(5, &ptr2);
Can full arrays be passed from flash memory as function arguments?
pgm_read_bytereturns, it can't be used as a pointer. And if it returns anint(as shown in the first code snippet) then why would you pass it as an array of bytes to thecallPGM2function?byte *is expected, and you have an array ofbyte, then passing the array as is will work just as fine as doing e.g.&array[0].pointer to PROGMEMas function argument, but don't mix it with non PROGMEM pointer. Would you mind to test this in real hardware, since I don't have it in my hand right now. If this is not what you mean, please ignore my comment.