help with 24lc128
Chet
Posts: 150
I have tried using the example given for the I2C memory, but continue to read either 0 or 255 on the inVal when using debug.· The 0 is with the pull-up resistor removes and the the 255 with it installed.· i have used two different new memory chips with the same result.
I·have grounded pins 1,2,3,4 and 7.· pin #5, SDA goes to RA.2 and pin #6, SCL goes to pin RA.3.· Both of the RA lines have a 4.7 K pull-up resistor.
In the step mode, I can see the SDA and SCL pulsing.
I am usign version 3.2
Any ideas?
Regards
Chet V
I·have grounded pins 1,2,3,4 and 7.· pin #5, SDA goes to RA.2 and pin #6, SCL goes to pin RA.3.· Both of the RA lines have a 4.7 K pull-up resistor.
In the step mode, I can see the SDA and SCL pulsing.
I am usign version 3.2
Any ideas?
Regards
Chet V
SXB
5K
Comments
The code you are starting with is for a 24LC16, which is smaller than the 24LC128 and has a simpler interface.· The 24LC128 is a 16Kx8 device, and it requires an extra address byte.· The 24LC128 is addressed by sending a control byte followed by the MSB and LSB of the address.· Since there are only 14 bits of address, the MSB has two "don't care" bits in the most significant bit positions.· You can set these two bits to zero.· Since you tied the three select address lines to ground, the control byte should have a value of A1 for reads and A0 for writes.
I would suggest that you do an internet search on the 24LC128 and read the data sheet.· I recently interfaced to a 24C512, and I had to read the data sheet several times before it made sense to me.· I wrote my code in assembly, but the high level read/write routines should look similar to yours.· I posted my code in the thread at http://forums.parallax.com/showthread.php?p=591787·.
Dave
Is there an SXB version of the code available. I am not familiar with assembly code for the sx yet.
Regards
Chet
Post Edited (Chet) : 9/9/2008 4:33:41 PM GMT
I think the following code should work.· I haven't tested it myself, so let me know if there's problems.
Dave
MEM_OUT:
· tmpW1 = __WPARAM12··················· ·' copy address
· I2CSTART SDA
· tmpB1 =·$A0················ ··················· ' ID with RW bit set to zero for write
· I2CSEND SDA, tmpB1··················· ·' send slave ID
· I2CSEND SDA, tmpW1_MSB·················· ·' send word address MSB
· I2CSEND SDA, tmpW1_LSB···················· ·' send word address LSB
· tmpB1 = __PARAM3························· ·' copy value
· I2CSEND SDA, tmpB1······················· ·' send data byte
· I2CSTOP SDA······························ ·' finish
· RETURN
MEM_IN:
· tmpW1 = __WPARAM12··················· ·' copy address
· I2CSTART SDA
· tmpB1 =·$A0········ ·························· ' ID with RW bit set to zero for write
· I2CSEND SDA, tmpB1··················· ·' send slave ID
· I2CSEND SDA, tmpW1_MSB·················· ·' send word address MSB
· I2CSEND SDA, tmpW1_LSB···················· ·' send word address LSB
· I2CSTART SDA····························· ·' restart for read
· tmpB1 =·$A1······ ··························· ' ID with RW bit set to one for read
· I2CSEND SDA, tmpB1··························· ' send slave ID
· I2CRECV SDA, tmpB1, Nak·················· ·' get one byte
· I2CSTOP SDA
· RETURN tmpB1
Thank you very much for your help.
Regards
Chet V