ATMega16 - Accessing EEPROM using Codevision

6 posts / 0 new
Last post
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

New to AVR Freaks!

Have a question accessing the EEPROM using Codevision. We are using the EEPROM to store nonvolatile cal/config data for an application. Looks like Codevision wraps up the EEPROM read and writes in their library so all you have to do is declare a variable as eeprom (ex. eeprom int Cal_Value;) and that stores that variable in EEPROM automatically storing a value in EEPROM when you assign it to that variable.

My question is if this is the case when I compile why does Codevision give me a warning that the eeprom variable in uninitialized?? That's the whole point, I don't want it initialized when I start up. I want to be able to use the last value stored in eeprom for this variable before that last power down. Or does initializing an eeprom declared variable only assign a default value that is only stored during the initial chip programming??

Am I missing something? Should I not use the Codevision eeprom declaration and store necessary data in the eeprom manually as described in the AVR ATMega16 user's guide?? :?:

Thanks in advance!!

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

prflory wrote:

... Looks like Codevision wraps up the EEPROM read and writes in their library so all you have to do is declare a variable as eeprom (ex. eeprom int Cal_Value;) and that stores that variable in EEPROM automatically storing a value in EEPROM when you assign it to that variable. ...

Yes, it is pretty transparent except for a couple of caveats like passing pointers (they must be of the type that the called routine expects).

Quote:

My question is if this is the case when I compile why does Codevision give me a warning that the eeprom variable in uninitialized?? That's the whole point, I don't want it initialized when I start up.

I understand your point. An SRAM global variable will indeed be given its intial value at each startup.

A CodeVision EEPROM variable, however, is >>not<< re-initialized every time that your AVR starts up. Rather, the initial values are used to produce the .EEP file at compile time. Then your programming system will/could program the EEPROM when the FLASH is re-programmed.

There are some here that never produce the EEPROM file, choosing to check the uninitialized EEPROM for the erased 0xff value for each byte and then do an initial configuration.

I do it the other way: I give all my EEPROM variables an initial value for a default configuration for a newly programmed system.

Feel secure that the EEPROM won't be re-initialized every startup. I've had all kinds of things in EEPROM on apps where flash became tight--menu strings, conversion factors, pointers to menu strings, etc.

Try a small trivial app with a few global SRAM & EEPROM variables with initializers, and then examine the startup flow in the resulting .LST file. [Remember that if you use AVRStudio to step through the app (a VERY useful exercise), that when you get ready to "Go" you must pre-load your simulator EEPROM values if you use the initializers. In 3.5x it is on the File menu under Up/Download Memories, IIRC.]

Lee

You can put lipstick on a pig, but it is still a pig.

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

Hello,
I have a project and I want to store in eeprom of my AVR
without putting an initial value in declaration of variables,
I use codevision software,can you help me??
I am waiting....
thanks for this website.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
int eeprom variable;      // declare a variable in eeprom
...
int some_function()
{
    ...
    variable = 1234;      // give the variable a value.
    ...
}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks to you David..

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

Hello!
I am working with ATMEGA 8535 Ic ,I use codevision ,and a 4*3 keypad for numbers ONLY.
I need a method,that I can use to print strings and characters on the LCD from keypad.
Is that right that I use that keypad ,or I must build a special keypad??
and if I used a special keypad what is the C code shall I use??
thanks in advance.
:?: