Problem with PROGMEM

Hi all,

I have a bunch of 1024 byte blocks of data that I store in PROGMEM that look like this:

static const uint8_t frame0[] PROGMEM = {
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x7F,0x41,0x00,0x00,0x7F,0x04,
    0x08,0x10,0x7F,0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x7E,0x11,0x11,0x11,0x7E,0x00,
/////// snip ////////
    0x7F,0x08,0x14,0x22,0x41,0x00,0x7F,0x49,0x49,0x49,0x41,0x00,0x00,0x00,0x00,0x00,
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};

I load 120 of these into a MEGA2560 (total sketch size about 130K - most of it being PROGMEM).

Using "pgm_read_byte_far" I can read the bytes from any of these arrays just fine. BUT, if I have a program (sketch) that tries to read these sequentially, it won't run (doesn't seem to start).

So I tried loading a smaller number of arrays. It seems that if the total sketch size is under around 75K, it works... any larger and it won't start.

AVRDUDE uploads and verifies the whole sketch just fine, but it won't run. Even manually hitting reset after the load doesn't start the program.

Any ideas why the code loads just fine, but won't run if it's over around 75K when I a 256K MEGA?

Thanks.

you are ending up in far addresses space (pointers have the same size as uint16_t ) -> need to use pgm_get_far_address

see the comment at the end of this post by Whandall

J-M-L:
you are ending up in far addresses space (pointers have the same size as uint16_t ) -> need to use pgm_get_far_address

see the comment at the end of this post by Whandall

Actually, that was the FIRST thing I tried (converting the pointers to 32 bit addresses via pgm_get_far_address).
That didn't work either.

But, if I take a file that consists of 120 1K blocks and load it with an offset to place it above my sketch, then it works fine.

I converted the 120 1K blocks into one large 122880 file, then converted it to an Intel HEX file with a load offset of 16384 (to place it above my sketch). Then I access the data like this:

    while (1) {
        for (x = 0; x < 120; x+=1) {
            VFD.drawImage ((16384 + (x * 1024)), 0, 0, 128, 64);
        }
    }

This works fine.
If it were a "16 bit pointer" problem, then wouldn't it fail above 65535, not over 75K?