Hi Art & All,
Thanks to Art, I noticed similar I2CWRITE problem with different PIC and EEPROM (I use 18F4520 and 24C64).
So far I haven't use external EEPROM for storing anything, just used I2CREAD and that has worked very well.
Below is my test code for WRITE/READ for EEPROM. Test will be passed if X=0 (LED blinking slowly), if X > 0 then it fails immediately (LED blinking fast).
Code:
<code><font color="#000000">OSCCON = $70 <font color="#000080"><i>'Int CLK 8MHz
</i></font>OSCTUNE.6 = 1 <font color="#000080"><i>'PLL 4x
</i></font>ADCON1= %00001111 <font color="#000080"><i>'$0F = disable A/D converter
</i></font>TRISD.0 = 0
TRISD.1 = 1
TRISD.3 = 0
TRISE.4 = 0
<b>DEFINE </b>OSC 32
X <b>VAR BYTE
</b>Y <b>VAR BYTE
</b>SCL <b>VAR </b>PortD.0
SDA <b>VAR </b>PortD.1
LED <b>VAR </b>PortD.3
I2CDeviceEEprom <b>VAR BYTE
</b>I2CAddressEEprom <b>VAR WORD
</b>I2CDeviceEEprom=$A0
X=0 <font color="#000080"><i>'OK if EEPROM content is 00h and X = 0, if X > 0 then fails
</i></font><b>FOR </b>I2CAddressEEprom = 0 <b>TO </b>8191
<b>I2CWRITE </b>SDA, SCL, I2CDeviceEEprom, I2CAddressEEprom,[ X ], Error
<b>PAUSE </b>10
<b>I2CREAD </b>SDA, SCL, I2CDeviceEEprom, I2CAddressEEprom,[ Y ], Error
<b>IF </b>Y <> X <b>THEN GOTO </b>Error
<b>NEXT </b>I2CAddressEEprom
Blink:
<b>HIGH </b>LED
<b>PAUSE </b>1000
<b>LOW </b>LED
<b>PAUSE </b>1000
<b>GOTO </b>Blink
Error:
<b>HIGH </b>LED
<b>PAUSE </b>200
<b>LOW </b>LED
<b>PAUSE </b>200
<b>GOTO </b>error
<b>END</b>
</code>
No help from DEFINE I2C_SLOW or any other that I have tried so far (increasing PAUSE time between write and read, etc...).
Hardware is OK, because I have used it for other purpose and then PIC read only from EEPROM (same PIC and EEPROM). Pull-ups are 4.7k and very solid 5V (no dips). Data lines are quite short (~25mm). EEPROM is only device in I2C-bus. WP pin is grounded....
Sounds very similar problems as Art has.
BR,
-Gusse-
Bookmarks