How to store constants in ROM (Atmel)
<p>Good Day,</p>

<p>I am writing firmware for an ATMega645A using AtmelStudio 7.  I am starting a localization project and need to display messages on a 16x2 character display in 3 different languages.  The existing (English messages) are stored in SRAM, but I will end up overflowing this data memory space if I have to triple the number of messages.</p>

<p>SO, I am trying to store the messages in ROM where space is a-plenty.  Problem is, Atmel app notes are either (a) wrong or (b) incomplete because I have tried multiple methods per their suggestion and the code does not compile (ref: Atmel Tips &amp; Tricks App Note doc8453.pdf page 8, and <a href="http://www.atmel.com/webdoc/AVRLibcReferenceManual/FAQ_1faq_rom_array.html" rel="nofollow">http://www.atmel.com/webdoc/AVRLibcReferenceManual/FAQ_1faq_rom_array.html</a>).  My code looks like this:</p>

<pre><code>// before main(void)
#include &lt;avr/pgmspace.h&gt;
const char string_1[] PROGMEM = "String 1";
const char string_2[] PROGMEM = "String 2";
const char string_3[] PROGMEM = "String 3";
const char string_4[] PROGMEM = "String 4";
const char string_5[] PROGMEM = "String 5";

PGM_P string_table[5] PROGMEM =
{
  string_1,
  string_2,
  string_3,
  string_4,
  string_5
};
</code></pre>

<p>inside main(void) I have the following:</p>

<pre><code>char buffer[10];
PGM_P p;
int i;

memcpy_P(&amp;p, &amp;string_table[i], sizeof(PGM_P));
strcpy_P(buffer, p);
</code></pre>

<p>When compiling, I get a message:
variable 'string_table' must be const in order to be put into read-only section by means of '<em>attribute</em>((progmem))'</p>

<p>I have tried 'char' instead of 'const char', but nothing seems to compile.  Any advice on the proper syntax to get these static character strings to be stored in ROM would be greatly appreciated.</p>