Shop OBEX P1 Docs P2 Docs Learn Events
Atmel I2C EEPROM chips and — Parallax Forums

Atmel I2C EEPROM chips and

ArchiverArchiver Posts: 46,084
edited 2004-03-30 21:38 in General Discussion
I had been having some difficulties working with the Microchip
24LC515 I2C 512 kbit EEPROM chips, so I ordered a set of Atmel
AT24C512 chips (also 512 kbit) to try out instead. After
receiving them, I ran a test program which failed and started
reading over the data sheet to find the problem.

It appears that the Atmel chips require a "dummy write" operation
to reset the current memory location. This consists of sending
the device address with the R/W bit set to write and the memory
address, then sending a device address with the R/W bit set to
read and clocking in the data.

To my knowledge, the Basic Stamp can't do this. It seems
peculiar on the part of Atmel to read the data this way.

Anyway, this is something to keep in mind if you use some of the
Atmel I2C EEPROMs. I don't know how many chip models do this.

(The Microchip problem I was having was posted here about a year
ago - basically, I could only access half of each chip because it
appeared to ignore the "block select" bit)

- Mark

Mark D. Conner
E-mail: n9xtn@a...
Homepage: http://members.cox.net/mconner1
"Arrogance and stupidity, all in the same package.....how
efficient of you!" - Ambassador Londo Mollari, Babylon 5

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-03-28 22:52
    Actually, if I read that correctly - you're describing the correct I2C
    procedure. It might be the root cause of your MicroChip eeprom problems as
    well.

    The process to read is (in Pseudocode)

    Tell the EEProm which address you want to read from.
    I2CStart
    I2CWrite WriteCommand 'EEprom address 7 bits + 0/1 for read/write
    I2CWrite HighAddress 'High Address Byte of the value you want to read
    I2CWrite LowAddress 'Low Address Byte of the value you want to read
    I2CStart ' Start I2C again - note NO stop!
    Now you can actually read starting from the location specified
    I2CWrite ReadCommand
    I2CRead ReadAbyte, Ack
    I2CRead ReadAnotherByte, ACK
    I2CRead ReadLastByte, NACK 'Dont ACK the last byte read
    I2CStop



    >
    Original Message
    > From: Mark Conner [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=HQItKckGJyTgmSDxZcA2o01O4F9JrRdgjLohFS81OLq6DBlDaKHaAWPKHh5IfKgxIp6Jfac]n9xtn@c...[/url
    > Sent: March 28, 2004 1:29 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Atmel I2C EEPROM chips and "dummy write"
    >
    >
    > I had been having some difficulties working with the Microchip
    > 24LC515 I2C 512 kbit EEPROM chips, so I ordered a set of Atmel
    > AT24C512 chips (also 512 kbit) to try out instead. After
    > receiving them, I ran a test program which failed and started
    > reading over the data sheet to find the problem.
    >
    > It appears that the Atmel chips require a "dummy write" operation
    > to reset the current memory location. This consists of sending
    > the device address with the R/W bit set to write and the memory
    > address, then sending a device address with the R/W bit set to
    > read and clocking in the data.
    >
    > To my knowledge, the Basic Stamp can't do this. It seems
    > peculiar on the part of Atmel to read the data this way.
    >
    > Anyway, this is something to keep in mind if you use some of the
    > Atmel I2C EEPROMs. I don't know how many chip models do this.
    >
    > (The Microchip problem I was having was posted here about a year
    > ago - basically, I could only access half of each chip because it
    > appeared to ignore the "block select" bit)
    >
    > - Mark
    >
    >
    > Mark D. Conner
    > E-mail: n9xtn@a...
    > Homepage: http://members.cox.net/mconner1
    > "Arrogance and stupidity, all in the same package.....how
    > efficient of you!" - Ambassador Londo Mollari, Babylon 5
    >
    >
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    > Subject and Body of the message will be ignored.
    >
    > Yahoo! Groups Links
    >
    >
    >
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2004-03-28 23:35
    In a message dated 3/28/2004 4:33:25 PM Eastern Standard Time, n9xtn@c...
    writes:


    > I had been having some difficulties working with the Microchip
    > 24LC515 I2C 512 kbit EEPROM chips, so I ordered a set of Atmel
    > AT24C512 chips (also 512 kbit) to try out instead. After
    > receiving them, I ran a test program which failed and started
    > reading over the data sheet to find the problem.
    >

    I am using an Atmel AT25HP512 - -512Kbit - chip with great success. Page
    write only. 128 bytes per page, 512 pages. SPI 3-wire.

    Sid Weaver
    W4EKQ
    Port Richey, FL


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2004-03-29 00:53
    Hi Mark,

    It seems to me it should work fine with the "current read" or the
    "sequential read" modes. The BASIC Stamp should have a problem only
    with the "random read" mode. These EEPROM chips hold onto the last
    address that is written or read, and that address is maintained so
    long as the power is on. The address increments automatically with
    each read operation (modulo the memory size) or write operation
    (modulo the page size).

    I'd guess that if the Stamp sends the slaveID, followed by the 16 bit
    address, and then ack and stop, the address will be successfully
    loaded into the EEPROM's address register. And the Stamp can follow
    that with a current read or a sequential read. Are you saying that
    that is not the case? The protocol 'AT512 is not much different from
    other EEPROM memories like the popular '24LC128. Those also have the
    random read option, where a stop + start condition can be replaced
    with a shortcut start only between the random address write and the
    data read.

    Do you have the pullup resistors installed? Are you using a BS2p or
    pe, or an earlier stamp with bit-banged I2C?

    -- Tracy


    >I had been having some difficulties working with the Microchip
    >24LC515 I2C 512 kbit EEPROM chips, so I ordered a set of Atmel
    >AT24C512 chips (also 512 kbit) to try out instead. After
    >receiving them, I ran a test program which failed and started
    >reading over the data sheet to find the problem.
    >
    >It appears that the Atmel chips require a "dummy write" operation
    >to reset the current memory location. This consists of sending
    >the device address with the R/W bit set to write and the memory
    >address, then sending a device address with the R/W bit set to
    >read and clocking in the data.
    >
    >To my knowledge, the Basic Stamp can't do this. It seems
    >peculiar on the part of Atmel to read the data this way.
    >
    >Anyway, this is something to keep in mind if you use some of the
    >Atmel I2C EEPROMs. I don't know how many chip models do this.
    >
    >(The Microchip problem I was having was posted here about a year
    >ago - basically, I could only access half of each chip because it
    >appeared to ignore the "block select" bit)
    >
    >- Mark
    >
    >
    >Mark D. Conner
    >E-mail: n9xtn@a...
    >Homepage: http://members.cox.net/mconner1
    >"Arrogance and stupidity, all in the same package.....how
    > efficient of you!" - Ambassador Londo Mollari, Babylon 5
  • ArchiverArchiver Posts: 46,084
    edited 2004-03-29 08:33
    Hi Mark,

    The sequence to set the address without reading or writing anything
    _might_ be...:
    I2COUT 0,$A0,$12,[noparse][[/noparse]$34] ' set address $1234, but no
    extra data

    or, (only if you have a '2p version 1.3 with the optional high address)
    I2COUT 0,$A0,[noparse][[/noparse]$12,$34] ' set address $1234, but no
    extra data

    No guarantees that the above will work! It depends on the chip's
    internal logic--when does it latch the address? The I2C protocol
    does not make any real distinction between "address" and "data". It
    is the EEPROM chip that interprets the 2 bytes it receives after the
    slaveID as an address. The Stamp does tokenize the above cases
    differently, I am not sure why.

    I'm still surprised that the standard syntax does not work for you.
    I2CIN 0,$A1,$12\$34,[noparse][[/noparse]mybyte1, mybyte2,.....] ' read bytes
    Internally, AFAIK, the Stamp deals with that as a random read exactly
    according to the description in the data sheet, with the "dummy"
    write of the address followed by a start condition and immediately
    the read, as PatM outlined.

    That is why I asked about the pullups. Also, are you using p0, p8,
    x0 or x8 for the sda, double checked the wiring? Address pins on the
    EEPROM matched to the slaveID? Write protect pin grounded?

    -- Tracy


    >I'd guess that if the Stamp sends the slaveID, followed by the
    16 bit
    >address, and then ack and stop, the address will be successfully
    >loaded into the EEPROM's address register.

    OK. How do you do that with BS2p commands?

    > And the Stamp can follow
    >that with a current read or a sequential read. Are you saying
    that
    >that is not the case? The protocol 'AT512 is not much different
    from
    >other EEPROM memories like the popular '24LC128. Those also have
    the
    >random read option, where a stop + start condition can be
    replaced
    >with a shortcut start only between the random address write and
    the
    >data read.

    Near as I can tell, the only way to send an I2COUT command is to
    send an actual byte of data. I tried leaving the data argument
    off the command and the compiler said "no".

    >Do you have the pullup resistors installed? Are you using a
    BS2p or
    >pe, or an earlier stamp with bit-banged I2C?

    Yes, I use the pull-ups suggested in the BS2p docs. My BS2p is a
    version 1.2. Could that be a problem? I heard mention on the
    list of other I2C difficulties with <1.3 chips.

    - Mark
  • ArchiverArchiver Posts: 46,084
    edited 2004-03-30 21:38
    A followup on this issue of setting the address register in the eeprom.

    Either of the following two instructions will successfully set the
    address pointer in an 24LC128 to a value of $0134, without actually
    writing any data to the chip: This is not documented in the eeprom
    data sheet.
    I2COUT 0,$A0,$01,[noparse][[/noparse]$34] ' BS2p v1.2 or v1.3, BS2pe v1.0 or v1.1
    or
    I2COUT 0,$A0,[noparse][[/noparse]$01,$34] ' BS2p v1.3, BS2pe v1.0 or v1.1

    The following command will read the data starting at that location,
    without resetting the address. Note that this does not work on the
    BS2p v1.2, because it can't do an I2CIN without specifying an address.

    I2CIN 0,$A1,[noparse][[/noparse]x] ' BS2p v1.3, BS2pe v1.0 or v1.1
    ' reads byte at address $0134 set above
    I2CIN 0,$A1,[noparse][[/noparse]y,z] ' reads two more bytes with autoincrement

    This form would doubtless be faster than the form with the address,
    if you need to read a bunch of stuff in a loop.

    The usual method of using I2CIN with a random address setting also
    works, of course, with the 24LC128.

    I2CIN 0,$A1,$01\$34,[noparse][[/noparse]x] ' BS2p v1.2 or v1.3, BS2pe v1.0 or v1.1
    ' reads one byte from location $0134
    ' note--address autoincrements to $0135

    I don't know why that would not work on an 'LC512 or the Atmel part
    specifically, but I don't have one here to try. It does work on an
    'LC256 and the Catalyst 'WC256.

    -- Tracy
Sign In or Register to comment.