Placing a lookup table in flash

cancel
Showing results for 
Search instead for 
Did you mean: 

Placing a lookup table in flash

Jump to solution
171 Views
Contributor II

Using Codewarrior 6.3.  I can put a lookup table in RAM, but cannot seem to figure out the syntax to place it in ROM or flash memory.  Tried using extern, but then it seems the table is placed in ram and flash.  For placing the table in ram, I have this in the header along with the table values:

static const unsigned char temperature[250] = { ... };

Works fine in ram.

I tried this to get the table in flash:

In the header:

extern unsigned char temperature[250];

then in the code:

extern unsigned char temperature[44] = { ...};

This places the table in both ram and flash!

What is the correct syntax to place a table in flash?

Thank you!

0 Kudos
1 Solution
106 Views
NXP TechSupport
NXP TechSupport

Hi Tom

You can allocate a constant variable at an absolute address using the @ modifier.

For example allocating a constant called VersionNbr at address 0xF000 and initializing it to 2 is done as follows:

 

       const int VersionNbr @0xF000 = 2;

Same notation can be used for a constant string as follows

       const char VersionStr[] @0xF000 ="Version 4.6";

if you don't use @, CW will allocate const variable to  default const section automatically.

If this version number is not used anywhere in the application, you have to instruct the Linker to link it to the application even though it is not used.

This is done specifying the constant name in the .prm file ENTRIES block.

For example:

ENTRIES

  VersionNbr VersionStr

END

 

Last, please enable –Cc option in Compiler option setting panel.

 


Have a great day,
Jun Zhang

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

View solution in original post

2 Replies
106 Views
Contributor II

Thank you Jun!  Your solution saved me so much time!  Can you please provide a link to the document that has this information?  Thank you!

0 Kudos
107 Views
NXP TechSupport
NXP TechSupport

Hi Tom

You can allocate a constant variable at an absolute address using the @ modifier.

For example allocating a constant called VersionNbr at address 0xF000 and initializing it to 2 is done as follows:

 

       const int VersionNbr @0xF000 = 2;

Same notation can be used for a constant string as follows

       const char VersionStr[] @0xF000 ="Version 4.6";

if you don't use @, CW will allocate const variable to  default const section automatically.

If this version number is not used anywhere in the application, you have to instruct the Linker to link it to the application even though it is not used.

This is done specifying the constant name in the .prm file ENTRIES block.

For example:

ENTRIES

  VersionNbr VersionStr

END

 

Last, please enable –Cc option in Compiler option setting panel.

 


Have a great day,
Jun Zhang

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

View solution in original post