|
|
View previous topic :: View next topic |
Author |
Message |
jelodavid
Joined: 03 Apr 2005 Posts: 22 Location: Laguna Philippines
|
erasing eeprom content |
Posted: Tue Apr 19, 2005 3:48 pm |
|
|
Hello all!
Kindly help me on how to erase eeprom content...
Here's my partial code.......... Code: | // Save data to internal eeprom-----------------------------------------
void save_data()
{
if (data1==0)
{
lcd_putc("\fNo data to save...\n......Exiting");
delay_ms(2000);
return;
}
printf(lcd_putc,"\fSaving %lu to\ninternal memory",data1);
write_eeprom(address,make8(data1,0));
address++;
write_eeprom(address,make8(data1,1));
address++;
delay_ms(1000);
printf(lcd_putc,"\fMemory Save: %lu",data1);
delay_ms(1000);
}
// Recall data from internal eeprom--------------------------------------
void recall_data()
{
address=0;
all_data = make16(read_eeprom(address+1),read_eeprom(address));
delay_ms(30);
printf(lcd_putc,"\fMemory Recall:\n %lu",all_data);
delay_ms(3000);
}
// Reset data from internal eeprom--------------------------------------
void reset_data()
{
lcd_putc("\fResetting Data...");
delay_ms(500);
data1=0;
write_eeprom(address,data1);
lcd_putc("\fData reset");
delay_ms(500);
}
|
eeprom content will reset to zero if it's below 255 but nothing happen above 255 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Apr 19, 2005 4:24 pm |
|
|
Quote: | EEprom content will reset to zero if it's below 255 but nothing
happen above 255 |
Code: |
// Reset data from internal eeprom------------------
void reset_data()
{
lcd_putc("\fResetting Data...");
delay_ms(500);
data1=0;
write_eeprom(address,data1);
lcd_putc("\fData reset");
delay_ms(500);
} |
Your code would be better, for various reasons, if your functions used
parameter variables instead of using global variables.
Your problem is due to a misunderstanding of this function:
write_eeprom(address,data1);
The 2nd parameter, data1, is an 8-bit value. You can only write to
one byte of data eeprom each time the function is called. You're
assuming that it's a 16-bit value, and that you can erase two bytes
per function call. But you can't do that. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|