Need for help with EEPROM
Posted: 29 Sep 2020 22:40
I cannot get eeprom to work in AVR pascal for an ATMEGA328p, when I use the example in the help file it only work as long I have power on my device,
example I use following from example file:
for counter := 0 to 31 do EEPROM_Write(0x100 + counter, counter);
In datasheet I can use addresses from 0 to 1023
and when I read it back:
for counter := 0 to 31 do // Read 32 bytes block from address 0x100
begin
PORTC := EEPROM_Read(0x100+counter); // and display data on PORTC
Delay_ms(100);
end;
Then all works well but if I change my program and only want to read and not write to eeprom, then all byte I read is 255 ! ???
it have complete forgot the byte I write to eeprom before.
can anybody tell me what is wrong, I have read several time in the datasheet but cannot see what I do wrong.
really hope for a solution cos I need to store some data in the eeprom for to read everytime I turn on my project
Best regards Erik
example I use following from example file:
for counter := 0 to 31 do EEPROM_Write(0x100 + counter, counter);
In datasheet I can use addresses from 0 to 1023
and when I read it back:
for counter := 0 to 31 do // Read 32 bytes block from address 0x100
begin
PORTC := EEPROM_Read(0x100+counter); // and display data on PORTC
Delay_ms(100);
end;
Then all works well but if I change my program and only want to read and not write to eeprom, then all byte I read is 255 ! ???
it have complete forgot the byte I write to eeprom before.
can anybody tell me what is wrong, I have read several time in the datasheet but cannot see what I do wrong.
really hope for a solution cos I need to store some data in the eeprom for to read everytime I turn on my project
Best regards Erik