Shop OBEX P1 Docs P2 Docs Learn Events
eeprom address — Parallax Forums

eeprom address

TumblerTumbler Posts: 323
edited 2012-06-16 09:41 in Propeller 1
Hi

I want to use a second eeprom with the address pins A0= 3,3v, A1=gnd and A2=gnd
and John's i2c demo.

I think i have to change this line in the DAT section, but i don't know what this line means.

EE = $A0 | (%001 << 1)

Can somebody help me with this?
thx

Comments

  • MacTuxLinMacTuxLin Posts: 821
    edited 2012-06-12 21:29
    Another way to see this is:

    EE = %101000000 OR %00000010
    EE = %10100010
    EE = $A2
  • TumblerTumbler Posts: 323
    edited 2012-06-12 21:32
    And how to change this line for my setup?
    A0= 3,3v, A1=gnd and A2=gnd
  • MacTuxLinMacTuxLin Posts: 821
    edited 2012-06-12 21:39
    Tumbler wrote: »
    A0= 3,3v, A1=gnd and A2=gnd

    This means this EEPROM's address A0. Your 2nd EEPROM is A2? If so, A2 should be pull-up.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-06-13 00:19
    MacTuxLin wrote: »
    This means this EEPROM's address A0. Your 2nd EEPROM is A2? If so, A2 should be pull-up.

    I'm not sure what you mean by an address of "A2". The address pins are used to assign the EEPROM one of eight possible addresses.

    The address of the EEPROM has this format.

    p1010AAAX (I have to use a "p" instead of the percent sign because the forum software has a fit with the percent sign.)

    The "AAA" part corresponds to which address pins are pulled high. Pin A2 is the most signifiicant of these bits.

    "X" indicates if the command is to read or write.

    The original EEPROM on the Prop has all address pins connected to ground so the address is "p1010000X".

    If pin A0 is pulled high, then the address is "p1010001X" (or setting the last bit to zero initially, you'd use "p10100010").

    The first four bits of the address "p1010" is the device address. Since the following three bits can be changed by setting one or more of the address pins high, it's possible to have eight EEPROMs on the same I2C bus.

    This address information is covered pretty well in the datasheet. Microchip's datasheet has this information in section 5.0 "Device Addressing" (page 8).
  • blittledblittled Posts: 681
    edited 2012-06-13 05:06
    It looks like EEPROMS can be addressed by using HEX A0 and by using the A0-A2 lines. If you want a second EEPROM tie line A0 high. Since the EEPROMS are I2C the address must be shifted left 1 i.e. EE := A0 | (Address (From A0-A2 lines) << 1). I2C uses bit 0 to determine if it reading or writing to an EEPROM. So if you tie A0 high you use EE = $A0 | (%001 << 1)
  • TumblerTumbler Posts: 323
    edited 2012-06-13 10:41
    Okay, got it now. Thx all for the help.
  • TumblerTumbler Posts: 323
    edited 2012-06-13 11:13
    Below a part of the jm_i2c_demo:
    {{ 
                                     3.3v
                                   &#61463;  &#61463;  &#61463;  
                    24LC512        &#9474;  &#9474;  &#9474;
              &#9484;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9488;  &#9474;  &#61628;  &#61628; 4k7      
           &#9484;&#9472;&#9472;&#9508;1 A0        VCC 8&#9500;&#9472;&#9472;&#9496;  &#9474;  &#9474;     
           &#9507;&#9472;&#9472;&#9508;2 A1         WP 7&#9500;&#9472;&#9472;&#9488;  &#9474;  &#9474; 
           &#9507;&#9472;&#9472;&#9508;3 A2        SCL 6&#9500;&#9472;&#9472;&#9474;&#9472;&#9472;&#9531;&#9472;&#9472;&#9474;&#9472;&#9472;&#61610; SCL pin   
           &#9507;&#9472;&#9472;&#9508;4 GND       SDA 5&#9500;&#9472;&#9472;&#9474;&#9472;&#9472;&#9472;&#9472;&#9472;&#9531;&#9472;&#9472;&#61610; SDA pin             
           &#9474;  &#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9496;  &#9474;
           &#61464;                       &#61464;
    
           
       Be careful using this program with the boot EEPROM -- corrupting the program/data
       space can lead to expected results.  If boot EEPROM is 64K (24LC512) addresses from
       $8000 to $FFFF are safe (not used by Propeller).
           
    }}
    


    and line 51:
    EE = $A0 | (p001 << 1) ' device address

    That's for an eeprom with the A0 pin high, not the boot eeprom.
    A typo?
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-06-13 11:36
    Tumbler wrote: »
    EE = $A0 | (p001 << 1) ' device address

    That's for an eeprom with the A0 pin high,

    The above sets EE to $A2, which would be the address for an EEPROM with the A0 pin high.

    With all address pins low (as with the boot EEPROM), the address should be $A0.
  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2012-06-13 16:37
    I had much of the same confusion when creating my Secondary EEPROM Bootloader. Check out this thread to see if it helps at all:

    http://forums.parallax.com/showthread.php?129700
  • JonnyMacJonnyMac Posts: 9,194
    edited 2012-06-16 08:19
    That demo was a bit long in the tooth and I have made several improvements to my I2C object. The updated code and demo is posted in ObEx

    -- http://obex.parallax.com/objects/528/ (link corrected)

    You probably understand by now that the slave id for an I2C exchange is formatted thusly

    -- TTTTAAAM

    ...where TTTT is the device type (%1010 for EEPROMs and similar devices), AAA is the 3-bit address for the device (if addressable; RTCs, for example, are not and fixed at %000), and M is the mode bit (0 for write, 1 for read).
  • g3cwig3cwi Posts: 262
    edited 2012-06-16 08:22
    Jon

    Your link needs to be this:

    http://obex.parallax.com/objects/528/

    The one you posted only works for the submitter of the object.

    Cheers

    Richard
  • TumblerTumbler Posts: 323
    edited 2012-06-16 09:07
    Thx for the update John
  • JonnyMacJonnyMac Posts: 9,194
    edited 2012-06-16 09:41
    Thanks for the catch; link is corrected.
Sign In or Register to comment.