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, dke...@hiwaay.net ======================================================================== Whom computers would destroy, they must first drive mad. _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list