24LC128 I2CIN/I2COUT code fails while ShiftIn/ShiftOut code works
Ron Czapala
Posts: 2,418
I am experimenting with·a 24LC128 16K Eprom and a BS2P stamp.· I used the example code found here
http://www.parallax.com/Portals/0/Downloads/docs/prod/oem/24LC128-v2.0.pdf
The I2C code does not work - it always show·the value·read as 255 no matter what I attempted to store.
However, the BS2 example code using ShiftIN and ShiftOut works fine.
Any ideas??
Thanks for any help/suggestions.
Here is the BSP I2C code (the BS2 ShiftIn/Out code is lengthier - see above link)
· SDA PIN 14 ' I2C Serial Data Line
· SCL PIN 15 ' I2C Serial Clock Line
· '
[noparse][[/noparse] Variables ]
· value VAR Byte ' Variable Used To Store Value
· eeprom_add VAR Word ' EEPROM Address
· '
[noparse][[/noparse] Main Routine ]
· DO
··· DEBUG "Enter value to store from 0 to 255: "
··· DEBUGIN DEC3 Value
··· DEBUG CR, "Enter address to store ", DEC value, " at, 0 to 15999: "
··· DEBUGIN DEC5 eeprom_add
··· ' Writing Section
··· I2COUT SDA, $A0,eeprom_add.HIGHBYTE\eeprom_add.LOWBYTE, [noparse][[/noparse]value]
··· PAUSE 50 '20
··· ' Reading Section
··· I2CIN SDA, $A1,eeprom_add.HIGHBYTE\eeprom_add.LOWBYTE, [noparse][[/noparse]value]
··· DEBUG CR, "Value stored at location ",DEC eeprom_add,
········· " is ", DEC value, CR, CR, CR
· LOOP
·
http://www.parallax.com/Portals/0/Downloads/docs/prod/oem/24LC128-v2.0.pdf
The I2C code does not work - it always show·the value·read as 255 no matter what I attempted to store.
However, the BS2 example code using ShiftIN and ShiftOut works fine.
Any ideas??
Thanks for any help/suggestions.
Here is the BSP I2C code (the BS2 ShiftIn/Out code is lengthier - see above link)
· SDA PIN 14 ' I2C Serial Data Line
· SCL PIN 15 ' I2C Serial Clock Line
· '
[noparse][[/noparse] Variables ]
· value VAR Byte ' Variable Used To Store Value
· eeprom_add VAR Word ' EEPROM Address
· '
[noparse][[/noparse] Main Routine ]
· DO
··· DEBUG "Enter value to store from 0 to 255: "
··· DEBUGIN DEC3 Value
··· DEBUG CR, "Enter address to store ", DEC value, " at, 0 to 15999: "
··· DEBUGIN DEC5 eeprom_add
··· ' Writing Section
··· I2COUT SDA, $A0,eeprom_add.HIGHBYTE\eeprom_add.LOWBYTE, [noparse][[/noparse]value]
··· PAUSE 50 '20
··· ' Reading Section
··· I2CIN SDA, $A1,eeprom_add.HIGHBYTE\eeprom_add.LOWBYTE, [noparse][[/noparse]value]
··· DEBUG CR, "Value stored at location ",DEC eeprom_add,
········· " is ", DEC value, CR, CR, CR
· LOOP
·
Comments
·· I've never used the I2CIN/OUT commands before and didn't notice the limitation on which pins were supported.
I need to read more carefully!· Works great now...
Thanks very much!
- Ron