Internal eeprom acces with Atmega16

I have a problem with using the internal eeprom of the atmega16. I am using codevision C and in the help file they say to do something like this :

//declare global eeprom a=0;

then then you can write the eeprom with changing the value for a , the eeprom adress is the adress the compiler has given soo you should not worry about that.

but this doesnt work, in my opinion due that every time you restart your system the eeprom is erased and get the inital value of 0 due to the global declaration. They claim that this initial value is only been given when programming the atmega if i understand correctly, anyone exprience with this?

Thanks

Yannick

Reply to
Yannick
Loading thread data ...

I don't use this toolchain. However, I imagine what this really does is:

  1. declare a temporary RAM variable 'a'.

  1. declare an EEPROM value 'a' which is loaded with your initializer value. When you flash new code into the chip, as long as you haven't disabled this functionality, the EEPROM will be erased and reloaded. Programming the EEPROM area might be a separate step depending on your programming software (AVR Studio for instance it's a separate step - also for the various command-line utilities such as uisp, avrdude, and so forth).

  2. implement some bizarre functionality underlying the RAM copy of a which reads it and writes it from EEPROM when accessed at runtime.

I'd be very leery of something this "smart".

Reply to
larwe

The best place to ask this question is the CodeVision support forum on Yahoo.

Ken

formatting link

Reply to
KenLem

Hi,

I think you should read the EEPROM section in the datasheet for the Mega 16.

There is an example.

Regards Jens

"Yannick" skrev i en meddelelse news: snipped-for-privacy@j52g2000cwj.googlegroups.com...

Reply to
Jens Gydesen

Yes there is, for programming the eeprom externally electrical , but not how to do it internally with codevision C... maybe i just should do it in assembler but wanted to do it with the codevision code as this would be much easier...

Reply to
Yannick

Did you REALLY read the data sheet?

Get Atmel document doc2466.pdf from the Atmel Web pages and read pages 16 to 20 again.

--

Tauno Voipio
tauno voipio (at) iki fi
Reply to
Tauno Voipio

You are right, but it was confusing because they do not mention these pages in the table of contents for eeprom, if you see in the table of contents for programming memory you get to page 150 or something and there it is for externally program the memory... but yes indeed at page

16-20 it is described very well, it works perfect now... i had to look better, thanks for giving me the good pages:)

Yannick

Reply to
Yannick

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.