avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] String Arrays in FLASH & gccavr 3.0


From: Matthew . Cook
Subject: [avr-gcc-list] String Arrays in FLASH & gccavr 3.0
Date: Tue, 7 Aug 2001 11:13:41 +0930

Greetings,

I am wondering if anyone has a better method of defining arrays of null
terminated strings in FLASH.   With the additional overhead of reading
constant byte data from FLASH, reading pointers to strings in FLASH does
present some difficulty.   It is easy to write a macro to do the two byte
to pointer conversion, what I am having trouble with is *forcing* gcc 3.0
to put the pointer (address) in FLASH and not define it as constant data in
RAM.   Defining my constant strings such;

static __attribute__ ((progmem)) char* F_strings[] =
{
     "Menu1",
     "Menu2",
     "Menu3"
};

Results in the whole lot being placed in RAM, seems to ignore the attribute
directive.   Change it thus;

static __attribute__ ((progmem)) char c_string1[] = "Menu1";
static __attribute__ ((progmem)) char c_string2[] = "Menu2";
static __attribute__ ((progmem)) char c_string3[] = "Menu3";

static __attribute__ ((progmem)) char* F_strings[] =
{
     c_string1,
     c_string2,
     c_string3
};

Results in c_string1,2 &3 being placed in FLASH, but F_strings is still
retained in RAM (still ignores attribute), albeit this much smaller than
the first case.   Now how can I force the compiler to put F_strings[] in
FLASH aswell so I can point my macros at them ?   I am sure this is a
problem with my limited understanding of gccavr, I have done this
previously with Hitachi and a PC, but on those projects I didn't care if my
pointers and string data were in RAM or ROM.   Any clues ?

Matthew





reply via email to

[Prev in Thread] Current Thread [Next in Thread]