bzktust 发表于 2011-1-27 11:42:40

在CVAVR的环境下,mega162。可以在内部eeprom里面定义结构体吗?

如题。
也就是:
eepromstruct mode               
      {
          unsigned char heat_time;
          unsigned char keep_time;
          unsigned intvoltage;
      };
      struct mode mod;



编译时可以通过的。只是warming 里面会说eeprom忽视结构体。

请问大家,我想在eeprom中做一个表,存储几种模式。怎么做?

bzktust 发表于 2011-1-27 12:55:26

各位大侠。

machao 发表于 2011-2-8 15:30:39

以下来自CVAVR的HELP


Defining Data Types Previous Top Next

--------------------------------------------------------------------------------

User defined data types are declared using the typedef reserved keyword.
The syntax is:


typedef <type definition> <identifier>;


The symbol name <identifier> is assigned to <type definition>.
Examples:


/* type definitions */
typedef unsigned char byte;
typedef struct {
               int a;
               char b;
               } struct_type;


/* variable declarations */
byte alfa;


/* structure stored in RAM */
struct_type struct1;


/* structure stored in FLASH */
flash struct_type struct2;


/* structure stored in EEPROM */
eeprom struct_type struct3;

======================================================================================

Structures can be grouped in arrays.
Example how to initialize and access an global structure array stored in EEPROM:


/* Global structure array located in EEPROM */
eeprom struct eeprom_structure {
             char a;
             intb;
             char c;
             } se={{'a',25,"Hello"},
                     {'b',50,"world"}};


void main(void) {
char k1,k2,k3,k4;
int i1, i2;


/* define a pointer to the structure */
struct eeprom_structure eeprom *ep;


/* direct access to structure members */
k1=se.a;
i1=se.b;
k2=se.c;
k3=se.a;
i2=se.b;
k4=se.c;


/* same access to structure members using a pointer */
ep=&se; /* initialize the pointer with the structure address */
k1=ep->a;
i1=ep->b;
k2=ep->c;
++ep;   /* increment the pointer */
k3=ep->a;
i2=ep->b;
k4=ep->c;
}

tanghk 发表于 2011-7-4 20:15:06

标志
页: [1]
查看完整版本: 在CVAVR的环境下,mega162。可以在内部eeprom里面定义结构体吗?