[Top][All Lists]

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

Re: [avr-gcc-list] External EEPROM verses internal EEPROM data handling

From: Bob Paddock
Subject: Re: [avr-gcc-list] External EEPROM verses internal EEPROM data handling
Date: Mon, 4 May 2009 06:36:40 -0400

> I am relatively new, not only to Atmel but also to Embedded system.

> typedef struct eventdata
>        {       uint8_t unit_add;
>                uint8_t card_add;
>                uint8_t event_no;               //Event counter
>                uint8_t type;           //Event type
>                uint8_t year;           //rtc yesr
>                uint8_t month;          //rtc month
>                uint8_t day;            //rtc day
>                uint8_t hour;           //rtc hour
>                uint8_t min;            //rtc min
>                uint8_t sec;                    //rtc sec
>                uint16_t voltage[24];   // adc counts of 24 channels in an 
> array
>        } ED;           // total data = 58 bytes

Because of issues of structure packing it is better to define
structure items from
the largest to the smallest, ie. uint16_t should be first.  This is
more important
on 32bit processors and up than on the 8bit AVRs.

> ED ramdata;                             // current event data in ram
> ED temp_ramdata;                        // load eeprom data to this event 
> data for sending to uart
> ED EEMEM eepdata[60];                   // 60 events data on EEprom

> But now I am supposed to save around 500 events.
> So Internal EEPROM cannot be used. So we decided to use EXternal EEPROM on 
> I2C bus.

You still might want to buffer a couple of blocks of data in internal
EEPROM as it will be
faster to write than the external one.  That will give you some
recovery options if power
fails while you are writing data.  Depending on how important your
data is, give lots
of consideration to power fail and recovery.  Also keep in mind that
EEPROMs, both the
internal and the external ones, have limited write life times.
makes EEPROM (F-RAM) parts that have no write limits.

> 1. How to declare "ED EEMEM eepdata[60];"

explains how to use offsetof() from stddef.h for this problem.
offsetof() also removes
issues of structure alignment issues, if you don't mind a few bytes being wasted
in your memory.

> how to use above commands in external  EEPROM.

The library you found should document that.  Most likely you need to
buffer you data in RAM,
and the library will have the equivalent read/write commands as the
internal ones.

> I am feeling now, the external EEPROM data handling is very difficult.

Solving these types of challenges is what keeps working on Embedded Systems
from ever getting boring.  Look at how the internal EEPROM AVR-LibC works, to
get some ideas of how to make your external lib. work.


reply via email to

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