Writing to non-voltaile memory while running - ATMEGA16

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,
I have an ATMEGA16 application which requires that a user be able to change certain program constants. And I need those changes to remain in the event of a power outage. Is there a means of writing to a non-volatile memory in the atmega16 while running? I'd rather not use external memory, as I am about out of pins.

thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

One word - EEPROM. Non-volatile constants is the reason that the EEPROM exists. It isn't fast, mind you ( at least on write ), but it is easy enough to use. You didn't say what language / compiler you want to use, so it's impossible to say, syntactically, how to do it. But it'll be in the documentation.

Martin Jay McKee

As with most things in engineering, the answer is an unabashed, "It depends."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

That's good news. I only have about 10 bytes which have to be accessible to a user. I'm using Codevision, a recent version. I just upgraded a week ago. Do you have a code sample for writing to EEPROM?

thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Do you have a code sample for writing to EEPROM?

There are examples in your datasheet.
Be aware that the lowest EEPROM location has reputation to loose it's value, so it's better to start e.g. at 0x010.

Also be sure to enable BOD, since EEPROM might be corrupted if CPU is running below its rated voltage.

EEPROM is guaranteed to be written to 100.000 times. Even if that sound like a lot of time you will wear it out if you save to same locations too often.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
There are examples in your datasheet.
Which are unnecessary for CodeVision. Just declare the variable "eeprom". In fact, all C compilers for AVR (at least as far as I know), have methods to handle data in eeprom that do the necessary stuff for you.

Regards,
Steve A.

The Board helps those that help themselves.