I used the following for read write EEPROM:
- Code: Select all
Public Sub i2cwrite (paddress As ushort, pdata As Byte)
I2C.Start
I2C.WriteByte(I2C_EEPROM)
I2C.WriteByte(paddress)
I2C.WriteByte(pdata)
I2C.Stop
DelayMS(10)
End Sub
Public Function i2cread (pAddress As ushort) As Byte
I2C.Start
I2C.WriteByte(I2C_EEPROM)
I2C.WriteByte(paddress)
I2C.Restart
I2C.WriteByte(I2C_EEPROM + 1)
return I2C.ReadByte()
I2C.Acknowledge(IsNotAcknowledge)
I2C.Stop
End Function
now I addes 2 bytes for address:
- Code: Select all
Public Sub i2cwrite (paddress As ushort, pdata As Byte)
I2C.Start
I2C.WriteByte(I2C_EEPROM)
I2C.WriteByte(paddress.1)
I2C.WriteByte(paddress.0)
I2C.WriteByte(pdata)
I2C.Stop
DelayMS(10)
End Sub
Public Function i2cread (pAddress As ushort) As Byte
I2C.Start
I2C.WriteByte(I2C_EEPROM)
I2C.WriteByte(paddress.1)
I2C.WriteByte(paddress.0)
I2C.Restart
I2C.WriteByte(I2C_EEPROM + 1)
return I2C.ReadByte()
I2C.Acknowledge(IsNotAcknowledge)
I2C.Stop
End Function
In both cases I can address only the first 256 bytes of the memory, which is strange!
So how to address the whole memory? Any suggestions?
Also very weird, today I tried 24LC1025 (which is 128kb x 8bit EEPROM) -> It doesn't work at all! It has the same addressing mode as the 24LC32.... Hmmm.....
what else should I try ?!?