OK, I got EEPROM writes and reads working with a minimum of fuss. The macro offsetof() worked beautifully. I even understood how it was working!!!! Amazing. I found that I had to cast it as a (void*) when I went to use it in an eeprom_write_block() function. I even made that long instruction its own macro. So, a macro within a macro. worked the first time. I could not believe it. I was sure it was going to write somewhere off in address space causing a major crash! It simply worked. I have nearly completed all the "hard" basic interacting-with- hardware tasks. Soon, I will be implementing the interaction with external input hardware. Half of which will use pulse detector logic and latches. The rest will function as sense switches to alter what the LCD displays are doing. All in all it is going very smoothly. Once I get it finalized I will then see what the minimal AVR hardware is necessary and maybe make a custom PCB to mount it all. -Tony --- In AVR-Chat@yahoogroups.com, David Kelly <dkelly@h...> wrote: > On Mon, Apr 25, 2005 at 07:16:15PM -0000, arhodes19044 wrote: > > > > Yes, I can see that the structure will provide a convenient > > technique to read & write the entire block. > > > > It has been a long time since I worked with structures. Is there a > > way to get the offset of the element within the structure? > > Something like "&structure.element". This way, I can start with the > > location of the structure in SRAM or in EEPROM and then access the > > individual element by base + offset. Will sizeof() work with > > structure elements? > > Yes, and yes. > > But remember if one tries (&structure.element - &structure) pointer > arithmetic may come into play. Make casts to (size_t) before doing the > math. Thats the point of the offsetof() macro mentioned. > > #define offsetof(type, field) ((size_t)(&((type *)0)->field)) > > For the above to work your structure has to be in a typedef. > > -- > David Kelly N4HHE, dkelly@H... > ===================================================================== === > Whom computers would destroy, they must first drive mad.
Message
Re: need variables to be stored in EEPROM
2005-04-26 by arhodes19044
Attachments
- No local attachments were found for this message.