[En-Nut-Discussion] EEPROM use

Harald Kipp harald.kipp at egnite.de
Mon May 14 12:08:31 CEST 2012

Hi Ayman,

On 13.05.2012 10:16, Ayman Hendawy wrote:
> uint8_t  save = 99;
> uint8_t  load;
> OnChipNvMemSave ( 512, &save, sizeof(uint8_t));
> OnChipNvMemLoad ( 512, &load, sizeof(uint8_t));
>  But I never read 99 from load, I never read a correct value, I always read
> garbag data,

It should work. Did you get any warnings from the compiler?

> may be the problem in the addresses, but I tried to change it many times
> with different values with no result,

The ATmega128 got 4096 EEPROM bytes, so address 512 is OK.

> By the way may be the problem in the make file, how can I update make file
> to create the necessary file.

Nothing special is required in the Makefile.

I assume, that the problem is somewhere else. Do you know the following page?


If you like, you can replace NutNvMemXXX by OnChipNvMemXXX. The former is just more portable, because not every CPU has an on-chip EEPROM.

Are you aware, that the EESAVE fuse must be programmed to retain EEPROM contents during chip erase?



P.S.: Please let us know what you found out. I'm still missing your response to


I assume that you solved the problem. It may be helpful for others to know what went wrong. Thanks.

More information about the En-Nut-Discussion mailing list