Well, I have tried every combination with and without the resistors (pull-ups on data and clock lines and the inline resistor on /MCLR). But it does not seem to matter if I have the pull-ups or not. Or even the resistor on /MCLR for that matter. If they are there or not, I still read only zeros from my EEPROM. I did not have time to run down to the lab and use their scope, so I just used my digital multimeter to see if I was getting a reading out of the data or clock pins and I can not tell. I think it is just so fast that I could not pick it up anyway. I do not know how familiar you are with PicBasic code, but I used their sample program for I2C interface. The code is supposed to write to the EEPROM (data values equal to the data address). Then, read back that same data and put it out on an asyncronous serial pin. But their program has the same problem. It returns only zeros. I think that maybe I am not using the I2CRead function properly. Here is what I am doing:
Syntax:
I2CRead DataPin, ClockPin, ControlCode, DataAddress, Data
My Code:
B0 var byte 'This defines B0 as a one byte variable
I2CRead 0,1,$A0,0,[B0] 'This sets DataPin to 0
' ClockPin to 1
' ControlCode to $A0
' DataAddress to 0
' Data read should go into B0 variable
It is this last part that is confusing. The data from the EEPROM should be read into the variable B0. Now I should be able to manipulate B0 or compare B0 to something. But B0 is always zero. Either the data being read back is zero and that is being put in B0, or the data being read back is not actually being stored in B0 and B0 is just remaining empty. If you know the syntax, please let me know.
Also I decided to try reading and writing from the internal EEPROM just to see if I could get that to work. I used the following code:
W0 con 4
B0 var byte
Write 1, [W0] 'Writes to address 1 the value of W0, which is 4
pause 10
Read 1, [B0] 'Reads the value at address 1 into the variable B0
If B0 = 4 then
High 5 'Turns on the correct LED
else
High 4 'Turns on the wrong LED
endif
THIS WORKED PERFECTLY!! It wrote a 4 to the internal EEPROM then read that value back into the variable B0. I checked that B0 was 4 and then turned on the correct LED. This process should be the same for an external EEPROM using the I2C interface. That is the problem I am having. Thanks for all your help, let me know what you think.
** Chris **