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

How to file in a Eeprom
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Aug 09, 2007 9:21 am     Reply with quote

-1 is displayed because we use the %d specifier, better would have been to use %u because the variables are of the unsigned type. With %d the output will be 255.

-1 or 0xFF is a common default value for empty EEPROMs. It looks like the data is not written to the EEPROM. What is the type number of the EEPROM you are using?

Try replacing the delay_ms(5) in write_ext_eeprom() by
Code:
int8 status;
.
.
.
  // delay_ms(5);
  do
  {
    i2c_start();
    status=i2c_write(0xAE);
  } while (status != 0);
SET



Joined: 15 Nov 2005
Posts: 161
Location: Glasgow, UK

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Aug 09, 2007 9:26 am     Reply with quote

Didn't you change the structure accesses?

Code:
currentEntry->dd

should be
Code:
currentEntry.dd


etc, as ckielstra correctly advised.
-1's means you are reading FF (i.e blank values) from the EEPROM.
eeprom_programmer*
Guest







PostPosted: Thu Aug 09, 2007 10:22 am     Reply with quote

Sorry I changed the structure access probably just posted the wrong code.

I am using a 24L128 eeprom, Both Line pulled up to 5v through a resistor
Eeprom_programmer



Joined: 07 Aug 2007
Posts: 24

View user's profile Send private message

PostPosted: Thu Aug 09, 2007 10:31 am     Reply with quote

Thank you so much, ckielstra AND Set!
It finally works!

%d was the fault!!!
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Aug 09, 2007 11:34 am     Reply with quote

I'm happy for you the code is working. It's just that I can't imagine the simple %u change makes it work. With %u the output should have been 255. Now the behavior is not consistent and that gives me a bad feeling.

I can't find the specifications for an 24L128 so I had a look at the Microchip 24LC128. This chip has a write time of max. 5ms, the same as your delay in the write routine. I wouldn't design my program so tight to the specifications from the datasheet as it gives no room for error. Why not improve your write routine with my suggestion above? With the dynamic test you will never wait any longer than nescessary.
Eeprom_programmer



Joined: 07 Aug 2007
Posts: 24

View user's profile Send private message

PostPosted: Fri Aug 10, 2007 5:42 am     Reply with quote

I totally understand! And i will defenitely do as you suggested!
Eeprom_programmer



Joined: 07 Aug 2007
Posts: 24

View user's profile Send private message

PostPosted: Fri Aug 10, 2007 6:12 am     Reply with quote

The values was consistent and i received 255, but there was something the matter with my write routine. After fixing it the correct values was returned.

Thanks again for the valuable info!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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