Shop OBEX P1 Docs P2 Docs Learn Events
24LC128 I2CIN/I2COUT code fails while ShiftIn/ShiftOut code works — Parallax Forums

24LC128 I2CIN/I2COUT code fails while ShiftIn/ShiftOut code works

Ron CzapalaRon Czapala Posts: 2,418
edited 2009-04-18 03:59 in BASIC Stamp
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
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-04-18 03:18
    Read the description of the I2CIN/I2COUT statements. They only support SDA and SCL on two pairs of I/O pins, 0/1 and 8/9, not pins 14 and 15.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2009-04-18 03:59
    Mike,

    ·· 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
Sign In or Register to comment.