Shop OBEX P1 Docs P2 Docs Learn Events
Suggestions for 8k-32k 8 pin PDIP I2C EEPROM chips — Parallax Forums

Suggestions for 8k-32k 8 pin PDIP I2C EEPROM chips

ZootZoot Posts: 2,227
edited 2007-01-29 16:59 in BASIC Stamp
I'm currently using a 24LC32A 4k (bytes - 32kbit) I2C EEPROM in a BS2p40 project. I store music scores, LED display patterns, Emic text phrases, etc.

I'm out of room and want to change out the chip for something larger -- 8k-32k (bytes). I2C ready, and ideally, with the same pinouts.

Does anyone have suggestions and/or a Jameco or Digikey part number?

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

Comments

  • ForrestForrest Posts: 1,341
    edited 2007-01-08 01:43
    Use a 24LC128 (16 KBytes) or a 24LC256 (32 KBytes). They're widely available Mouser, Digikey, etc - just search for these part numbers. Pinout is the same on all 24LCxxx parts. All of these chips have 3 address lines (A0, A1 and A2) so you can string up to 8 of these chips together.
  • ZootZoot Posts: 2,227
    edited 2007-01-08 02:43
    Perfect. Thanks, Forrest.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • KatyBriKatyBri Posts: 171
    edited 2007-01-08 03:54
    Zoot,

    Could you post your code? I would like to see how your talking to a I2C ready EEPROM.

    Thanks.
  • ZootZoot Posts: 2,227
    edited 2007-01-08 04:55
    Sure, but it's not my doing, so don't give me credit smile.gif This is code based on examples from the PDF manual for the BS2p Development Board (which shipped with a 4k I2C EEPROM) and various examples at the forum. This relies on the I2CIN and I2COUT commands, which are available (someone correct me if I'm wrong) on the BS2p, BS2p40, BS2pe and BS2px. The Basic Stamp manual also has some examples listed under I2CIN and I2COUT.

    EEaddr VAR Word
    addrHi VAR EEaddr.HIGHBYTE
    addrLo VAR EEaddr.LOWBYTE
    ioByte VAR Byte
    ioWord VAR Word
    datHi ioWord.HIGHBYTE
    datLo ioWord.LOWBYTE
    
    'i2c
    I2Cw                  CON     0         'r/w bit write
    I2Cr                  CON     1         'r/w bit read
    'i2c addresses
    fourkee               CON     $A0       '24LC32A 4k EEPROM address
    fourkeemax            CON     $FFF      '4095      'highest address in 4k chip
    
    
    'set ioByte or ioWord to be your data to write, set EEaddr to memory address
    'a warning -- it takes time to write data -- time your program accordingly
    
    ioByte = $1A              'write a single byte
    EEaddr = $010           'some address
    GOSUB Put_fourkeeByte
    PAUSE 3
    
    ioWord = $1A1A              'write a word
    EEaddr = EEaddr + 1  'to next address
    GOSUB Put_fourkeeWord
    PAUSE 3
    
    EEaddr = $010     'read a byte
    GOSUB Get_fourkeeByte
    DEBUG "address: ", HEX4 EEaddr, ", data: ", IHEX2 ioByte
    
    EEaddr = $011     'read a word
    GOSUB Get_fourkeeWord
    DEBUG "address: ", HEX4 EEaddr, ", data: ", IHEX4 ioWord
    
    DO : LOOP
    
    'etc.........
    
    
    Get_fourkeeByte:        'parameters: fourkAddr in 4K eeprom; returns: ioByte
       I2CIN SDA, fourkee | I2Cr, addrHi\addrLo, [noparse][[/noparse]ioByte]        ' read it back
       'DEBUG IHEX4 fourkeeaddr, ":", DEC3 ioByte, CLREOL, CR            'otherwise, print EEaddr and data and play the note
       RETURN
    
    Put_fourkeeByte:        'parameters: fourkAddr in 4K eeprom; ioByte = data to write
       I2COUT SDA, fourkee | I2Cw, addrHi\addrLo, [noparse][[/noparse]ioByte]
       RETURN
    
    Get_fourkeeword:       'parameters: fourkAddr in 4K eeprom; returns: ioWord
       I2CIN SDA, fourkee | I2Cr, addrHi\addrLo, [noparse][[/noparse]datLo, datHi]        ' read it back
       RETURN
    
    Put_fourkeeword:       'parameters: fourkAddr in 4K eeprom; ioWord = data
       I2COUT SDA, fourkee | I2Cw, addrHi\addrLo, [noparse][[/noparse]datLo, datHi]        ' read it back
       RETURN
    
    



    But there's a million ways to do it depending on your program needs. I read/write Byte streams sometimes as shown below, but check the Pbasic Stamp manual for details -- when writing arrays, the write terminates if the byte is $00 so you can get burned if you need to write $00 as data in your stream...

    EEaddr VAR Word
    addrHi VAR EEaddr.HIGHBYTE
    addrLo VAR EEaddr.LOWBYTE
    buffer VAR Byte(8)   'this example is 8 bytes max read/write
    j  VAR Nib  '= how many bytes to read, write
    
    
    'i2c
    I2Cw                  CON     0         'r/w bit write
    I2Cr                  CON     1         'r/w bit read
    'i2c addresses
    fourkee               CON     $A0       '24LC32A 4k EEPROM address
    
    'pause after writing byte stream would be critical, btw
    
    Get_fourkeebytes:       'parameters: j = how many bytes, EEaddr = address in 4K eeprom; returns: buffer array
    I2CIN SDA, fourkee | I2Cr, addrHi\addrLo, [noparse][[/noparse]STR buffer\j]        ' read 'em back
       RETURN
    
    Put_fourkeebytes:       'parameters: j = how many bytes, EEaddr = address in 4K eeprom, buffer = data array
       I2COUT SDA, fourkee | I2Cw, addrHi\addrLo, [noparse][[/noparse]STR buffer\j]        ' read it back
       RETURN
    
    
    

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

    Post Edited (Zoot) : 1/8/2007 4:59:58 AM GMT
  • KatyBriKatyBri Posts: 171
    edited 2007-01-08 23:19
    Zoot,

    Thanks very much for taking the time to post the code. It was very helpful.
  • abcdefgabcdefg Posts: 10
    edited 2007-01-29 16:25
    Would that code work with this EEPROM IC?

    http://www.sparkfun.com/datasheets/IC/24LC256.pdf

    Also, is there code like this that will work with just the BS2 stamp?

    Post Edited (abcdefg) : 1/29/2007 4:47:16 PM GMT
  • ZootZoot Posts: 2,227
    edited 2007-01-29 16:59
    Yes. The 24LC256 is basically the same, just more bytes. If you are writing multiple bytes at once just watch for "page wrap" on the 32 byte boundaries (i.e., you can't write multiple byes in one shot to addresses 30-36 as that would cross the page boundary at byte 32 -- you can only write multiple bytes to addresses in 32 byte chunks -- 0-31, 32-63, etc)

    If you want to run I2C commands from a BS2, there are bit-bang subroutines (by Jon Williams I think) that will handle this (since I2C is not "native" on the BS2):

    http://forums.parallax.com/showthread.php?p=466264

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
Sign In or Register to comment.