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

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

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


From: David Kelly
Subject: Re: [avr-gcc-list] External EEPROM verses internal EEPROM data handling
Date: Mon, 4 May 2009 08:46:36 -0500
User-agent: Mutt/1.4.2.3i

On Mon, May 04, 2009 at 10:21:50PM +0930, Daniel O'Connor wrote:
> On Mon, 4 May 2009, Bob Paddock wrote:
> > > ? ? ? ? ? ? ? ?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.

I suspect this is a homework assignment and the structure was provided.

> You could just mark the struct as packed, eg..
> typedef struct eventdata {
>  ...
> } __attribute__ ((packed)) ED;

Yup. Should also verify that sizeof(ED) == 58 in the code.

When allocating memory and calculating offsets into the EEPROM one
should use sizeof(ED) rather than a hard coded constant.

If I was defining the ED structure then I'd store 4 bytes of seconds
since some epoch rather than 6 bytes of year, month, day, hour, minute,
second. Much simpler, and routines to convert from seconds are readily
available in OS's and spreadsheets.

-- 
David Kelly N4HHE, address@hidden
========================================================================
Whom computers would destroy, they must first drive mad.




reply via email to

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