programming Atmega64 eeprom

Dear friends ; I am working with avr Atmega64 chip on a project .In my project i have to save my last data in a variable in eeprom and reload it in the flash variables when the chip is being restarted . I program the chip with JTAG ICE STK 500 programmer.i use these code in my program that is written in code vision for saving the data: //variable definition eeprom int eeGP; int GP; ;/main function eeGP=0x08; GP=eeGP;

the problem is that in first programing i give a value to the eeGP and i expect that after programming the chip if i erase the flash and reload the program without giving a value to the eeGP the value of GP changes to 08.(the eeprom has been programmed) but the thing happen is that after reloading the program to the chip the GP takes the

0xFFFF value that means the eeprom hasn't been programmed. I have enabled the fuse bit (preserve eeprom on each chip erase.

Thanks in Advance

Reply to
Sara
Loading thread data ...

Are you really trying to reload FLASH variables when the chip is being restarted??? You can change data in FLASH but that would mean reprogramming the chip using ISP.

I think you mean reload SRAM variables, which is evidently what you are trying to do in the code posted above. If you reprogram the chip, while preserving EEPROM, you should expect the data in eeGP to remain at 0x08, but the value of GP will be indeterminate when the program starts, depending on the data initialization properties of your C compiler. After you run the program, GP should reflect the value of eeGP.

How are you checking the value of GP? With a debugger?

By the way, you should use commas, etc., when you write. A little more punctuation (and capitalization) would have made your post much easier to read.

Like this:

-- Joe

Reply to
J.A. Legris

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.