Shop OBEX P1 Docs P2 Docs Learn Events
EEPROM Question — Parallax Forums

EEPROM Question

FalconFSXFalconFSX Posts: 1
edited 2009-09-27 18:29 in BASIC Stamp
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.

Comments

  • aliniousalinious Posts: 51
    edited 2005-03-21 05:08
    First, you should connect pin 5 of the 24LC32A to pin 0 of your Basic Stamp, then Pin 6 of the 24LC32A should be connected to pin 1 of the Basic Stamp. Also, Pin 5 should be connected to the VDD pin of 24LC32A through a 4.7K resistor, and the same should be done for pin 6.

    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.
  • chris joneschris jones Posts: 391
    edited 2009-09-26 17:34
    Hello

    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.
  • vaclav_salvaclav_sal Posts: 451
    edited 2009-09-27 04:56
    Before you write the software I would recommend to you to check this datasheet first.
    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.
  • ZootZoot Posts: 2,227
    edited 2009-09-27 05:21
    alinious is correct -- the key here is that the 24LC32A uses a WORD address for reading and writing (the memory address in the EEPROM you want to read/write). That's the 0\0 in his code. The Pbasic manual is your friend here -- I2CIN and I2COUT accept either Byte or Word sized addresses; in the latter case the high and low byte of the address are split by the backslash.

    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
  • dev/nulldev/null Posts: 381
    edited 2009-09-27 09:02
    With pullups:

    attachment.php?attachmentid=64031

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don't worry. Be happy
    548 x 434 - 19K
  • chris joneschris jones Posts: 391
    edited 2009-09-27 17:43
    Hello

    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.
  • ZootZoot Posts: 2,227
    edited 2009-09-27 18:29
    Chris Jones -- given that FalconFSX started this thread related specifically to the 24LC32A and the BS2p/BS2p40 built-in I2C commands, if you are not using that setup, would you start a new thread (forum topic) with info about the specific Stamp and EEPROM you are using?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
Sign In or Register to comment.