Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: need variables to be stored in EEPROM

2005-04-26 by arhodes19044

--- In AVR-Chat@yahoogroups.com, David Kelly <dkelly@h...> wrote:
> I don't quite follow your problem. Does this answer your question?
> 
> #include <avr/eeprom.h>
> 
> typedef struct {
> 	int	a,
> 		b,
> 		c;
> 	char	s[32];
> } EEDATA;
> 
> EEDATA eedata __attribute__ ((section (".eeprom")));
> EEDATA data;
> 
> void
> main()
> {
> 	while(1) {
> 		data.a = 0;
> 		eeprom_read_block( &data, &eedata, sizeof(data) );
> 		
> 		data.a++;
> 		eeprom_write_block( &data, &eedata, sizeof(data) );
> 	}
> }
> 
> -- 
> David Kelly N4HHE, dkelly@H...
> 
=====================================================================
===
> Whom computers would destroy, they must first drive mad.


Yes, this does show it explicitly.  I tried something similar, but 
allocated individual variables instead of a structure because I will 
nearly always be accessing them totally individually, only once in 
the beginning as a block.

When I did this and initialized the eeprom variables, I got odd, 
numbers looking like uninitialized data (in avr studio watch 
screens).  When I read and wrote them I still got numbers that were 
not the uninitialized strange #'s.  I will look at this more....

-Tony

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.