basic stamp 2p40 cannot read 24lc128 eeprom chip.. help!!
PHM102
Posts: 27
we have troubleshoot the circuit of the 24lc128 for several times... we have even change the 24lc128 chip.. however, it still not working when·running the demo·program·(I2CIN·and I2COUT)...· can someone provide help in this? could it be bs2p40 faulty?
Comments
·
·· Do you have the 4.7K resistors on the SDA/SCL lines?· What do you mean it’s not working?· What exactly is happening?· Do you have code you can post?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
anyway this is the program,
' {$STAMP BS2p}
' {$PBASIC 2.5}
#IF ($STAMP < BS2P) #THEN
· #ERROR "Program requires BS2p, BS2pe, or BS2px."
#ENDIF
SDA············ PIN···· 0·············· ' I2C SDA pin
SCL············ PIN···· SDA + 1
addr··········· VAR···· Word··········· ' internal address
block·········· VAR···· Nib············ ' block address in 24LC16
value·········· VAR···· Byte··········· ' value to write
check·········· VAR···· Nib············ ' for checking retuned values
result········· VAR···· Byte(16)······· ' array for returned value
Write_To_EEPROM:
· DEBUG "Writing...", CR
· PAUSE 2000
· FOR addr = 0 TO 2047 STEP 16········· ' loop through all addresses
··· block = addr.NIB2 << 1············· ' calculate block address
··· value = addr >> 4·················· ' create value from upper 8 bits
··· ' write 16 bytes
··· I2COUT SDA, $A0 | block, addr, [noparse][[/noparse]REP value\16]
··· PAUSE 5
··· DEBUG "Addr: ", DEC4 addr, "-", DEC4 addr + 15, "· ",
········· "Value: ", DEC3 value, CR
· NEXT
· PAUSE 2000
Read_From_EEPROM:
· DEBUG CR, "Reading...", CR
· PAUSE· 2000
· FOR addr = 0 TO 2047 STEP 16
··· block = addr.NIB2 << 1
··· value = addr >> 4
··· I2CIN SDA, $A1 | block, addr, [noparse][[/noparse]STR result\16]
··· FOR check = 0 TO 15
····· IF (result(check) <> value) THEN Error
··· NEXT
··· DEBUG "Addr: ", DEC4 addr, "-", DEC4 addr + 15, "· ",
········· "Value: ", DEC3 result, CR
· NEXT
· PAUSE 100
· DEBUG CR, "All locations passed"
· END
Error:
· DEBUG "Error at location: ", DEC4 addr + check, CR,
······· "Found: ", DEC3 result(check), ", Expected: ", DEC3 value
· END
Randy
·
·· Since the code you posted appears to be for the 24LC16, please try the code for the 24LC128 posted at the following link and see if that works for you.· Be sure you set the I/O lines in the code the same as you’re using…Take care.
http://www.parallax.com/detail.asp?product_id=602-00013
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
EDIT: Tried the sample program and it works but would like to ask what does the "eeprom_add.HIGHBYTE\eeprom_add.LOWBYTE" does?
Post Edited (PHM102) : 12/5/2006 6:48:31 AM GMT
edit;
' {$STAMP BS2p}
' {$PBASIC 2.5}
SDA··········· PIN····· 0············· ' I2C Serial Data Line
SCL··········· PIN····· 1············· ' I2C Serial Clock Line
ee_addr··· VAR··· Word
value····· VAR··· Word
ee_addr = $50
I2COUT SDA,$A0,ee_addr.HIGHBYTE\ee_addr.LOWBYTE, [noparse][[/noparse]200]
I2CIN SDA, $A1,ee_addr.HIGHbyte\ee_addr.LOWBYTE, [noparse][[/noparse]value]
·DEBUG DEC value
i am trying to store a value of 200 to address $50 then read out the value from address $50. However it came out 255 instead of 200. urgent help is needed. thanks
Post Edited (PHM102) : 12/6/2006 8:57:30 AM GMT
·
·· Did the program I referred you to work as it is for you?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Randy
·
·· Please see Randy’s reply above…If you’re trying to store values greater than 255 then you need to store two bytes and move two address positions for each write.· Is this where you’re having trouble?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support