CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Struct to eeprom write routine, saving only different bytes.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

Struct to eeprom write routine, saving only different bytes.
PostPosted: Mon Jan 10, 2005 3:54 pm     Reply with quote

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

View user's profile Send private message

Re: Struct to eeprom write routine, saving only different by
PostPosted: Mon Jan 17, 2005 12:25 pm     Reply with quote

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?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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