24LC128 memory chip problem
guru1
Posts: 8
I recently bought the 24LC128 memory chip to interface with my BS2P24. I tried the following code to verify whether it works.
SDA··········· PIN····· 0············· ' I2C Serial Data Line
SCL··········· PIN····· 1············ ' I2C Serial Clock Line
val VAR Byte
val=$8
· 'Writing secion
· I2COUT SDA, $A0,12, [noparse][[/noparse]val]
· PAUSE 200
··' Reading Section
· I2CIN SDA, $A1,12, [noparse][[/noparse]val]
· DEBUG CR, "Value stored is ", HEX val, CR
I keep getting "FF" as the result no matter what value I put fro "val". I'm sure of all my connection are correct. Any help will be greatly appreciated. Thanks in advance
Post Edited (guru1) : 5/12/2007 3:45:15 AM GMT
SDA··········· PIN····· 0············· ' I2C Serial Data Line
SCL··········· PIN····· 1············ ' I2C Serial Clock Line
val VAR Byte
val=$8
· 'Writing secion
· I2COUT SDA, $A0,12, [noparse][[/noparse]val]
· PAUSE 200
··' Reading Section
· I2CIN SDA, $A1,12, [noparse][[/noparse]val]
· DEBUG CR, "Value stored is ", HEX val, CR
I keep getting "FF" as the result no matter what value I put fro "val". I'm sure of all my connection are correct. Any help will be greatly appreciated. Thanks in advance
Post Edited (guru1) : 5/12/2007 3:45:15 AM GMT
Comments
Also, not a code expert, but are you waiting the required time after a write before trying to read the value?· The writes on the chip takes a few milliseconds.·
Maybe run the write part before the read part?· It looks like your code reads the previous value, then writes a new one.
I also take it that you manually change the constant "val" to get different values?
I hope this helps!
Post Edited (Desy2820) : 5/12/2007 2:49:10 AM GMT
Since EEPROMs expect a 16 bit address, you have to use the high\low address format. As Desy2820 mentioned,
you must have the pull-up resistors shown in the PBasic manual and you have to wait at least 20ms after a write
before doing anything else with the EEPROM (read or write).
With the larger EEPROMs, you include the high order bits of the EEPROM address as part of the "slave ID".
You should read the datasheet for the EEPROM device for specifics. That will also discuss "page mode".
It's working like magic now. Thanks for all your help.