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 support@ccsinfo.com

I2c External eeprom

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



Joined: 06 Jan 2013
Posts: 39

View user's profile Send private message

I2c External eeprom
PostPosted: Fri Mar 29, 2013 9:16 am     Reply with quote

Where can i find an example for external eeprom I2c memory?

I try to read/write to a 24AA02 eeprom but since i don't have any experience with I2c i have a lot of problems. (If i study an example it would be more easy to understand the concept).
temtronic



Joined: 01 Jul 2010
Posts: 9169
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Mar 29, 2013 10:23 am     Reply with quote

First place would be in the 'examples' folder of the compiler ! TONS of working example code there for almost any peripheral you would want to use.
Next, try the 'Code Library' on this site.....
And, search this fourm with appropriate 'keywords'...

hth
jay
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Fri Mar 29, 2013 10:50 am     Reply with quote

There's a 2402.C in the CCS drivers folder.

Check the data sheets, it's probably exactly what you want.

Mike

EDIT It you've followed temtronics advice you should have found it by now!
Tom1234



Joined: 06 Jan 2013
Posts: 39

View user's profile Send private message

I2c External eeprom
PostPosted: Fri Mar 29, 2013 6:39 pm     Reply with quote

I used the example 2402.c with main :
Code:

for(i=0;i<5;i++)
  {
   write_ext_eeprom( i,i);
   delay_ms(15);
  }

for(i=0;i<5;i++)
  {
   printf("MEMORY:%d\n",read_ext_eeprom(i));
  }

and is look like that is working ok.

Is anyone who can explain the code ( 2402.c) what is the logic for this code and why is used the address 0Xa0,0Xa1??


The 2402.c code:
Code:

c:\program files\picc\drivers\2402.c   



++++++++++++++++++++++
Code deleted. Directory location substituted. See forum rule #10:
10. Don't post the CCS example code or drivers
http://www.ccsinfo.com/forum/viewtopic.php?t=26245

- Forum Moderator
++++++++++++++++++++++
branko



Joined: 26 Mar 2013
Posts: 8
Location: Russia

View user's profile Send private message

Re: I2c External eeprom
PostPosted: Fri Mar 29, 2013 11:23 pm     Reply with quote

Tom1234

0xa0 is the address of the eeprom device you are using and 0xa1 is the address to read the eeprom ie., first you issue an 0xa0 address to eeprom which will be a write operation then to change the direction that is from write to read you write 0xa1. So, the next operation will be a read operation.
_________________
Regards
Branko
Ttelmah



Joined: 11 Mar 2010
Posts: 19358

View user's profile Send private message

PostPosted: Sat Mar 30, 2013 12:44 am     Reply with quote

Start by going on-line, and downloading 'I2C bus specification 1995.pdf'. This is the key document to I2C. There have been later extensions to this, but it is the 'core' of I2C. Look then at figures 12, 13 & 14, which show 'how' an I2C transfer takes place.

Best Wishes
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Sat Mar 30, 2013 6:59 am     Reply with quote

Latest I2C manual I got from Philips is 2000. Most of changes should not affect you.

Read the forum guidelines. Tells you what is / isn't acceptable, such as posting CCS examples.

I suggested you looked at the data sheets. They also show you how to read/write EEPROM. CCS code should more or less follow data sheet version.

There have been lots of threads here on EEPROM problems.
It may be worth your while to verify that you have actually written to the EEPROM.
To test you could:-
1) Read EEPROM before writting something different to it.
2) Remove EEPROM from PCB (or at least remove power) then re-test.
3) Try (if possible) to change VDD by 10% or so, to verify you're not in a marginal condition.

Mike
temtronic



Joined: 01 Jul 2010
Posts: 9169
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Mar 30, 2013 7:15 am     Reply with quote

also...
be sure to use the correct value I2C bus pullup resistors !
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