Defining & referencing static data structures in FLASH

Discussion created by FridgeFreezer on Nov 2, 2009
Latest reply on Nov 3, 2009 by Tom Thompson

I'm maintaining some old code for the M.Core MMC2114 in CodeWarrior 4.1 / 0622 (yes I have to shovel coal into the laptop to make it run!) and have hit a problem I can't work out the answer to, although I'm sure it's a simple thing.


Basically, within the code are arrays of strings, system messages, which are in several different languages. Currently the code loads one set of strings into a struct in RAM at runtime, something very roughly like:


void load english(){for(number of messages){copy ENGLISH_MESSAGE_NUMBER -> sys_messages[MESSAGE_NUMBER] }


So say we have 200 messages, we store N * 200 text strings (N = number of translations) in FLASH, and then copy one load of them to RAM at runtime. :smileysurprised:

What I'd like to do is just define all the messages in the code and then point to their location in flash, so they could be addressed something like this:


sprintf(sys_messages[%LANG][MSG_HELLO]) // Prints "hello" in chosen language

So %LANG is a variable that indicates the selected language.


What I'm stumped by is how to define this lot as a pile of static data rather than have to clog up the available RAM with a copy of data which is never going to change?


(I would add that I didn't write the original code, so I don't need to be told it makes no sense!)