|
|
View previous topic :: View next topic |
Author |
Message |
future
Joined: 14 May 2004 Posts: 330
|
Struct to eeprom write routine, saving only different bytes. |
Posted: Mon Jan 10, 2005 3:54 pm |
|
|
This routine was already posted by me in the past.
Now I want it to save only the modified bytes, but it doesnt work. Only a test to verify if the data is different was added.
Did I something wrong?
Code: | if(!EECON1bits.WR)
if(eeprom_count<sizeof(cfg))
{
EEADR=eeprom_count;
EEDATA=*(&cfg+EEADR);
if(EEDATA!=read_eeprom(EEADR))
{
disable_interrupts(GLOBAL);
EECON1bits.EEPGD=0; // point to data memory
EECON1bits.WREN=1; // enable writes
EECON2=0x55;
EECON2=0xAA;
EECON1bits.WR=1; // begin write
enable_interrupts(GLOBAL);
}
eeprom_count++; // increment index pointer
}
else {
eeprom_count=0;
EECON1bits.WREN=0; // disable writes
} |
|
|
|
Thomas Blake
Joined: 18 Jan 2004 Posts: 22 Location: Burbank CA
|
Re: Struct to eeprom write routine, saving only different by |
Posted: Mon Jan 17, 2005 12:25 pm |
|
|
future wrote: | Now I want it to save only the modified bytes, but it doesnt work. Only a test to verify if the data is different was added.
|
Why not use the CCS functions? Using CCS functions,
if (read_eeprom(i) != n) write_eeprom(i, n);
where i is the address and n is the data, works fine as a conditional eeprom write for any purpose.
But this reminds me of something I've wanted to ask the forum - does the Microchip EEPROM write algorithm automatically not do equal overwrites, as part of its endurance-enhancement process? |
|
|
|
|
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
|