I2c and eeprom problem

pwaggie

New Member
Hi,
After building several Picaxe projects I decided to have a go playing with a 24LC128 but have not been able to succeed and maybe someone could spot what I am doing wrong, I have reduced the circuit and program to the bare minimum and tried several variations but still cannot get it to work.
This is a 18m2 with only a 24LC128 attached with address lines A0-2 all taken to ground as is WP
Here is the code I am using but all I get when reading the data back is 255 %11111111

Main:

i2cslave %10100000, i2cfast, i2cbyte

writei2c 0,("Hello",255)
pause 10

readi2c 0, (b0,b1,b2,b3,b4)
debug b0

end


If I attach an axe033 module with clock chip inserted I can access the module and user ram on the clock chip with i2c and no problems, but when I try it with the 24LC128 I get the results above. I bought 3 of these IC’s from Rapid and get the same for all of them so I don’t think it’s a faulty IC.
Any help would be appreciated.
 

Jamster

Senior Member
I dont know much about I2c but i would guess at the fact you are using i2cslave, I think you need to use I2cmaster.
 

hippy

Ex-Staff (retired)
The 24LC128 is a word addressed Eeprom so you need I2CWORD not I2CBYTE in the I2CSLAVE command. It's also best to use I2CSLOW until things are working then move to I2CFAST.

If that doesn't fix things, which firmware version of the 18M2 are you using ?
 

MartinM57

Moderator
I dont know much about I2c but i would guess...
You're doing it again Jamster ;)

There is no "i2cmaster" command, but you're probably thinking about HI2CSETUP I2CMASTER, slaveaddress, mode, addresslen which is now the normal way of configuring and using I2C...

...manual 2 says "i2cslave - This command is depreciated[sic], please consider using the hi2csetup command instead."
 

pwaggie

New Member
Many thanks for your replies, it was the i2cword (thanks hippy) that was the problem, I thought as I was trying to write bytes then it should be i2cbyte.

It now works in both old and new commands also i2cfast and i2cslow.

Thanks again
 
Top