Yahoo Groups archive

AVR-Chat

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

Message

Re: Saving configuration in internal EPROM!

2005-12-25 by Don Kinzer

--- In AVR-Chat@yahoogroups.com, "filipesbp" <filipesbp@s...> wrote:
> I'm trying to make a project that needs to store the configuration 
> when the power is off. I'm a C programmer (I use Avredit), and the 
> only thing that i can find in Google is store e a external EPROM and 
> the code is in assembly.
> Can some one tell me how can i do this in c? 

You can store data in the internal EEPROM.  You can even store data in 
internal flash.  Both memories, however, have write cycle limitations; 
something on the order of 100,000 writes is the guaranteed minimum.  
Consult the datasheet for the particulars.

The details of how you read and write EEPROM and flash depend on what 
compiler you're using.  It is very likely that there are library 
routines, provided with the compiler that you're using, specifically 
for these purposes.  With WinAVR, there is a series of functions, all 
beginning with the prefix eeprom_ for reading and writing.  Similarly, 
there is a series of functions for reading/writing flash memory.  
Consult the documentation for your compiler or post a question on the 
message board for your compiler.

Of course, you can always drop down to assembly language.  This is 
especially easy if your compiler supports in-line assembly code.  If 
not, it probably supports separately compiled/assembled object modules 
so you could still use the assembly language code and design a C-
language interface to the routines.

Don
ZBasic Microcontrollers
http://www.zbasic.net

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.