Using PROGMEM for an array of structs

I'm not expecting an answer, just making an observation.

I'm using a Mega. I have several arrays of structs to provide lookup tables for my application. I fetch strings and pre-calculated values to determine feed rates, limits and display parameters to implement an "electronic lead screw" for a lathe.

Just for kicks I tried moving them into flash using PROGMEM, and got it to compile without complaint.

The problem is that it ALMOST works (don't you just hate that?). It returns wrong members and corrupted data, and makes for some very interesting display artifacts on the Nextion display that I'm using.

I suspect something like a RAM buffer size mismatch/overrun, but I'm going to have to get a lot closer to the memory limits before I go trying to track it down.

Cheers.

Probably some mistaken use of PROGMEM. You could start with some simple code and if it will not work you can post it here for discussion.

You do understand that retrieving data from PROGMEM requires a different, specialized technique than plain old dynamic memory?

memcpy_P is your friend :slight_smile:

sterretje:
memcpy_P is your friend :slight_smile:

Thanks for the memory jog. I neglected to include this: AVR program space functions.