Freescale Semiconductor
CodeWarrior General
Register  ·  Sign In  ·  Help
Jump to Page:   1
  Reply  

Defining & referencing static data structures in FLASH
Options    Options  
FridgeFreezer
Visitor
Posts: 8
Registered: 2009-07-30


FridgeFreezer

Message 1 of 2

Viewed 80 times


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!)

 

 

2009-11-02 05:53 PM
  Reply  

Re: Defining & referencing static data structures in FLASH
Options    Options  
Moderator J2MEJediMaster Moderator
Moderator
Posts: 1057
Registered: 2006-03-23


J2MEJediMaster

Message 2 of 2

Viewed 58 times


I remember M*Core. One of those steam-powered processors. :smileyhappy:

 

Check out FAQ-28651 and FAQ-27630. Both deal with storing constants in ROM (flash). The first FAQ is for the HCS12(X) MCU, and the second is for a Power Architecture CPU, but maybe they'll give you some ideas. Sorry I cannot give you something specific on M*Core.

 

---Tom

 

2009-11-03 02:34 PM
Jump to Page:   1