Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Atmega168 eeprom problem

Status
Not open for further replies.

kandhu26

Member level 5
Joined
Sep 7, 2009
Messages
93
Helped
13
Reputation
26
Reaction score
12
Trophy points
1,288
Location
chennai / bangalore
Activity points
1,858
Hii... I am using ATMEGA168 for my project... My project requires EEPROM... ATMEGA168 has internal EEPROM [512bytes]... So, I went with internal EEPROM because totally i want to store 64 bytes only... Actually EEPROM is working properly [I can able to write as well read the data]... But the problem is When i program my code EEPROM is getting reseted... All the address is filled with spaces... when you dont do reprogram, EEPROM is working pefectly... I have checked with turning off the power and turning on the power.... Its working perfectly until if you dont do reprogramming...:oops:
Please anyone can help me out of the situation...
Thanks in Advance...
 

when you program it. do not program the EEPROM.
Also do not erase the mcu. becasue it erase all the memories and the EEPROM.

I think the best solution for you is to put the initial value of EEPROM at your program.
:)
 

kandhu,

If you are using a common Atmel programming software (i.e., programming the chip from AVR Studio), the first step of the "programming process" is to erase the chip, including EEPROM. To avoid this, you need to change one of your fuses. In the fuse high byte, bit 3 (0 indexed), you need to set the EESAVE bit to 0 (programmed). Be careful! While you can't "toast" a chip with improper fuse settings, you can greatly complicate reprogramming it (i.e., if you change the clock settings to a value that is incompatible with your design). Read about the fuse bytes in the datasheet -- section 27 in my copy, p. 284 -- 287.

Secondly, unless you only have a single variable stored in EEPROM, if you recompile your program, it is unpredictable whether the addresses assigned to the variables will be the same or not. There are two workarounds for this. You can create a struct, and store all of your eeprom variables in the single struct. Then, through recompiles, the first variable will always be stashed in the same address (assuming you don't change compilers). If you need to add more variables, just add them at the end of the struct. This is kind of a cheap solution, but it works pretty well. An more elegant (and complicated) alternative is to reserve a block of eeprom memory (by editing your make file). Then you can explicitly assign the variables in question to specific addresses in the reserved block. The hard coded addresses obviously don't change, and because the block is reserved, auto-generated (i.e., "EEMEM") variables will not be placed there without an error at compile time.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top