搜索
bottom↓
回复: 3

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

[复制链接]

出0入0汤圆

发表于 2011-1-27 11:42:40 | 显示全部楼层 |阅读模式
如题。
也就是:
eeprom  struct mode               
        {
          unsigned char heat_time;
          unsigned char keep_time;
          unsigned int  voltage;
        };
        struct mode mod[8];  



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

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

阿莫论坛20周年了!感谢大家的支持与爱护!!

如果想吃一顿饺子,就得从冰箱里取出肉,剁馅儿,倒面粉、揉面、醒面,擀成皮儿,下锅……
一整个繁琐流程,就是为了出锅时那一嘴滚烫流油的热饺子。

如果这个过程,禁不住饿,零食下肚了,饺子出锅时也就不香了……《非诚勿扰3》

出0入0汤圆

 楼主| 发表于 2011-1-27 12:55:26 | 显示全部楼层
各位大侠。

出0入0汤圆

发表于 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[5];
               } 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;
             int  b;
             char c[15];
             } se[2]={{'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[0].a;
i1=se[0].b;
k2=se[0].c[2];
k3=se[1].a;
i2=se[1].b;
k4=se[1].c[2];


/* 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[2];
++ep;   /* increment the pointer */
k3=ep->a;
i2=ep->b;
k4=ep->c[2];
}

出0入0汤圆

发表于 2011-7-4 20:15:06 | 显示全部楼层
标志
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-3-28 21:56

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表