View previous topic :: View next topic |
Author |
Message |
Tom1234
Joined: 06 Jan 2013 Posts: 39
|
I2c External eeprom |
Posted: Fri Mar 29, 2013 9:16 am |
|
|
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: 9243 Location: Greensville,Ontario
|
|
Posted: Fri Mar 29, 2013 10:23 am |
|
|
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
|
|
Posted: Fri Mar 29, 2013 10:50 am |
|
|
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
|
I2c External eeprom |
Posted: Fri Mar 29, 2013 6:39 pm |
|
|
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
|
Re: I2c External eeprom |
Posted: Fri Mar 29, 2013 11:23 pm |
|
|
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: 19539
|
|
Posted: Sat Mar 30, 2013 12:44 am |
|
|
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
|
|
Posted: Sat Mar 30, 2013 6:59 am |
|
|
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: 9243 Location: Greensville,Ontario
|
|
Posted: Sat Mar 30, 2013 7:15 am |
|
|
also...
be sure to use the correct value I2C bus pullup resistors ! |
|
|
|