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

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

Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?


From: Jesper Hansen
Subject: Re: [avr-gcc-list] Initilizing complex const arrays : syntax ?
Date: Sun, 18 Sep 2005 11:23:56 +0200
User-agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)

Yes, but that was not the original question.

On a mega128, you can have quite a lot of these structs without a problem.
I'll leave it up to the OP to ask again, if that is a problem.
No need to complexify the answer unnecessarily.
Otherwise we could just reply to all questions with a full AVR/C tutorial.

/Jesper

Anton Erasmus wrote:
On 18 Sep 2005 at 9:36, Jesper Hansen wrote:


It's just as before; one element at a time.
In this case, your element is the first structure :

struct param param_list[] = {
{ "Engine Speed", "RPM", "%4d" },
{ "Coolant Temp", "°C", "%3.1f" },
{ "Turbo Pressure", "Bar", "%2.1" },
{ e.t.c. },
{ NULL, NULL, NULL }
};

Note that as another example, I left out the length of the param_list,
you can detect the end by checking for the NULL pointers.


The problem with this using avr-gcc, is that the data is stored in RAM, and not 
in
FLASH. This makes the use of these sorts of structures much more problematical.
In order to access any data in flash using avr-gcc, one needs in essence to get a pointer that points to the specific data one wants to read.
Regards
  Anton Erasmus


Vincent Trouilliez wrote:

Hi,


I know how to initialize arrays with one dimension, like this :

const type variable[3] = {value1, value2, value3 };


but now I am having to initialize an array of structures, and I am
getting lost :-/ Here is my declaration :


ui.h
----
//data type for one engine parameter
struct param {
                char    desc[11];       //parameter name ("Engine Speed", 
"Coolant
Temp",...)                 char    unit[4];        //unit to be used ('%', "RPM", 
"°C",
"Bar" ...)            char    format[6];      //printf format string: how to 
format
the number on the LCD
};


//table containing the definition for all engine parameters
extern const struct param param_list[30];


What's the syntax to initialize my "param" array above ?!


Thanks in advance... :-)



Regards,


--
Vince



_______________________________________________
AVR-GCC-list mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list




_______________________________________________
AVR-GCC-list mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list






reply via email to

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