EEPROM Question
FalconFSX
Posts: 1
Ok, I'm simply trying to write and read from a 24LC32A EEPROM.· (Just using numbers).· I'm having a heck of a time getting this to work with mixed results.· Here is my code (note: using BS2p40 on the demo board):
value·· VAR···· Byte
Setup:
· value = 20
Main:
· I2COUT 0, $A0, 0, [noparse][[/noparse]DEC value]
· PAUSE 1000
· I2CIN 0, $A1, 0, [noparse][[/noparse]DEC value]
· PAUSE 1000
· DEBUG "Test: ", DEC value, CR
· PAUSE 1000
· END
Its nothing fancy, yet I always get 0 back.· I'm not sure if its a code problem or what.· I have Pins 5 & 6 of the EEPROM tied into iB1 & iB2 for the 4.7k resistor.· Should I be using a seperate 4.7k resistor instead?· (in other words, don't use the board)· I was thinking as simple as this is it shouldn't be that hard.· Or am I using the I2 commands incorrectly?
Thanks in advance.
value·· VAR···· Byte
Setup:
· value = 20
Main:
· I2COUT 0, $A0, 0, [noparse][[/noparse]DEC value]
· PAUSE 1000
· I2CIN 0, $A1, 0, [noparse][[/noparse]DEC value]
· PAUSE 1000
· DEBUG "Test: ", DEC value, CR
· PAUSE 1000
· END
Its nothing fancy, yet I always get 0 back.· I'm not sure if its a code problem or what.· I have Pins 5 & 6 of the EEPROM tied into iB1 & iB2 for the 4.7k resistor.· Should I be using a seperate 4.7k resistor instead?· (in other words, don't use the board)· I was thinking as simple as this is it shouldn't be that hard.· Or am I using the I2 commands incorrectly?
Thanks in advance.
Comments
Second, in your code try this: I2COUT 0, $A0, 0\0, [noparse][[/noparse]value] and I2CIN 0, $A1, 0\0, [noparse][[/noparse]value]
If this works out better for you, I can explain the commands further, or pages 205 to 218 of the 2.1 Basic Stamp Manual can further clarify the commands.
If you need any more help, I will gladly be of assistance.
i am haveing a big issue with the EEPROm can someone send me a pic of how my pins need to be setup i can not read or erite anything. i tried the datasheet and a google search that was given to me by parallax and neather are helping.
http://ww1.microchip.com/downloads/en/DeviceDoc/21713H.pdf
Pay close attention to the address selection, initialization and then to the I2C write / read protocol.
BTW you do not need 1 second pause between write / read cycle. The corect timing is somewhere in the above mentioned spec. If you want I could send you my code , but it is for different EEPROM and does not use I2C commands.
It may be confusing.It's your call.
dev/null's circuit is incorrect in two places. You need a 1.8k-4.7k pullup resistor on BOTH SDA and SCL (not a series resistor). On the demo board, as you indicated, you can use the "built-in" pullups by running additinonal wires from the SDA and SCL pins to the pullup headers on the (and make sure the jumper is set to enable them).
Secondly, A0-A2 must be tied to either ground or 5v to set the address of the DEVICE itself. Easiest is to ground all three (resulting in a device address of $A0). If you had more than once I2C device on the same bus, however, you could change this address).
Third, as in dev/null's diagram, make sure the write protect pin of the EEPROM is pulled low.
Lastly, you have a crucial conceptual error in your own code -- you do NOT want to use the DEC formatter in the I2COUT -- you just want to write the value. You may want to format incoming data for better presentation, as you've done.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't worry. Be happy
i am haveing problerms connecting my stamp to my eeprom i was told by parallax that a pdf is online i tried that exmaple and it does not work can you please show me a image of the eeprom on a board and cnected i have a board of education for the stamp.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php