I'm having this problem in Arduino, but I posted on the arduino.cc forum and didn't get a reply, so I thought I'd try over here. After all, there IS an AVR in there ( ) and I think this is more of a C conceptual problem than an Arduino problem.
I create a struct like this:
typedef struct{ uint16_t height; uint16_t width; uint16_t bytes; const unsigned char dig[820] PROGMEM; } digit;
I create an instance of it like this:
digit One = {31, 122, 16, {0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, [remainder of array omitted for brevity] ... }};
I pass elements of this instance to a function like this (X and Y are defined elsewhere):
Partial_Update_Display_Area(X, Y, One.width, One.height, One.dig);
If I create the array as a stand alone array, and use its name (One_Partial) in the function call like this:
Partial_Update_Display_Area(X, Y, One.width, One.height, One_Partial);
everything works fine. If I pass One.dig to the function, it causes runtime (not compile time) errors (the function causes a bitmap to be sent to an epaper display; the error takes the form of garbage in the form of part of a wrong bitmap being sent to the display, as if the function is reading from the wrong part of flash). I assume I'm not passing the array (well, technically, the address of the first element of the array) correctly when it's part of the struct, but maybe I'm doing something else wrong. Anyway, any tips greatly appreciated.