Thread: EEPROM Code
View Single Post
  #7   Spotlight this post!  
Unread 12-10-2005, 11:53
kc8nod's Avatar
kc8nod kc8nod is offline
Registered User
AKA: Ted Hansen
FRC #1216 (Knights)
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Oak Park Michigan
Posts: 43
kc8nod is on a distinguished road
Re: EEPROM Code

Hi Kevin,

Thanks for all the effort, it looks great and we'll definately be using it. I'd like to make one suggestion though.
With so many novice progammers using your code, it's likely that someone will use the EEPROM_Write() function too much, even when the data doesn't need to be updated. A small change to EEPROM_Write() might avoid problems for these folks.

Code:
unsigned char EEPROM_Write(unsigned int address, unsigned char data)
{
     unsigned char return_value;

     // determine if this is really new data
     if(data == EEPROM_Read(address))
     {
          return_value = 1;
     }	
     else if(eeprom_queue_full == FALSE) // return error flag if the queue is full
     {
          // put the byte and its address on their respective circular queues
          eeprom_queue_data[eeprom_queue_write_index] = data;
          eeprom_queue_address[eeprom_queue_write_index] = address;
If the new data being written, is the same as the old data that's already there, then we never add it to the queue.

Thanks again for all the hard work.