Shop OBEX P1 Docs P2 Docs Learn Events
24LC32A chip programming — Parallax Forums

24LC32A chip programming

bond999bond999 Posts: 1
edited 2007-02-23 16:58 in BASIC Stamp
.

Post Edited (bond999) : 3/7/2007 11:38:36 PM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-31 06:44
    The Stamp DIscovery Kit is a good way to get started with Stamp processors. There's an article in the Nuts and Volts column www.parallax.com/dl/docs/cols/nv/vol3/col/nv88.pdf on using a similar memory chip with a BS2 like in the kit. There are other Nuts and Volts columns that also talk about using an I2C buss to access memory and/or other devices. Have a look through them on the Parallax website.

    The 24LC32A is a 4Kx8 EEPROM chip. Most of these articles use a larger chip, like 32Kx8, but the programming is the same, just a smaller number of locations are available.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-12-31 17:29
    EPROM/EEPROM programmers can read and write (copy) I2C data.· Maybe you have one already, maybe a friend, or one at work?
  • Larry~Larry~ Posts: 242
    edited 2006-12-31 20:31
    Can't you hook up a stamp to the old and new at the same time and read address1 old, then program address1 new and so on
  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-31 20:40
    Yes, you can. You can actually hook both to the same bus (SDA to SDA to Stamp pin x, SCL to SCL to Stamp pin y). In this case, you need to connect each EEPROM's address select lines differently. A1 and A2 of both should be grounded (zero). A0 and WP of the old EEPROM should be grounded. A0 and WP of the new EEPROM should be connected to +5V (Vdd or Vcc). All grounds should be connected to the Stamp ground (Vss) and all +5V (Vdd or Vcc) should be connected to the Stamp Vdd. With this setup, the old EEPROM will be at addresses 0-4095 and the new EEPROM will be at addresses 4096-8191. The old EEPROM will be write protected.

    You can use the "read a byte" and "write a byte" routines from the article I mentioned to copy the data and verify it. Just be sure to wait 5ms ("PAUSE 5") after each write.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-12-31 20:43
    Yes, you could have a couple of I2C EEPROMs and read one into a Stamp and then write that data to the other.· (If you want to go to all of that trouble.)·

    I was just suggesting that if bond999 had access to a programmer that he might go that route.· It seems that copying the EEPROMs is his objective.· I don't figure him to be a "Stamper."

    _____________________

    bond999,

    If you decide to buy a Stamp, etc.·to do this, then buy a BS2p, BS2pe, or BS2px because with those you can use the I2CIN and I2COUT commands and that'll make the project ultra-easy.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-01-01 01:35
    Bond999,
    ·
    ·· Is this a BASIC Stamp-based device?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-23 04:23
    Well, you also need "pull-ups" on SDA and SCL. Take two resistors with values somewhere between 4.7K and 10K. Connect one between SDA and Vcc and the other between SCL and Vcc.

    You will need a program in the Stamp to read the contents of the 24LC32A EEPROM and copy it to the Stamp's own EEPROM using the WRITE statement (and probably display it on the PC in the process). I think the Nuts and Volts article gives the subroutines to read one location from the EEPROM and some general discussion of what they do and how they work. You will need a second program that will read the data from the Stamp's own EEPROM using the READ statement and copy it to the new 24LC32A EEPROM one byte at a time. Typically, you'll write both programs using Jon Williams' programs as starting points, then download (from the PC) and run (and debug) the first program. Once that's working, you can swap EEPROMS, download the second program and debug it. Once it's working satisfactorily, you'll be able to just restart the Stamp and it will program a new EEPROM from the copy of the data in the Stamp's program EEPROM. The Stamp has a total of 2K of EEPROM and most programs don't occupy the whole thing. When you download a new program from a PC using the Stamp Editor, it leaves the part of the EEPROM untouched that's not occupied by your program. This can be used for data storage as in this case subject to the limitations of EEPROMs in general (mostly limits on how many times you can change a given location ... on the order of 100K to 1 million times).
  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-23 06:34
    I'll put together some simple "pseudo-code" tomorrow. In the meantime, read the PBasic Manual section on the DATA/READ/WRITE statements and ask questions about what you don't understand after you read it.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-02-23 15:38
    Bond999,

    You will probably want the 4.7K (typical in I2C devices) for pull-ups. A note on the WRITE command though…You won’t be using it in this application. WRITE only affects the internal EEPROM. You can also check the follow sources for additional wiring and code examples for the 24LC32A. Take care.

    ·

    http://www.parallax.com/dl/docs/cols/nv/vol5/col/nv115.pdf

    http://www.parallax.com/dl/docs/books/sw/stampworksmanualv1_2.pdf

    (See experiment #32, Page 197)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Mike GreenMike Green Posts: 23,101
    edited 2007-02-23 16:58
    Bond999,
    I've rethought this a little and I think a direct copy from one EEPROM to another is in order. You need to connect another 8-pin socket in parallel with the one you currently have with Vss, Vcc, SDA, and SCL all in parallel. All the WP, A2, and A1 pins are connected to Vss. One A0 (the read socket) is connected to Vss. The other A0 (the write socket) is connected to a 4.7K resistor and the other end of the resistor is connected to Vcc. Have a look at page #214 of the Nuts and Volts article (NV115). It has a one byte read routine that will read from address "wrdAddr" into "i2cData" using the "read socket". Here's the code (obviously it relies on a variety of subroutines in Jon's example program on pages 222-224 which will have to be included).
    wrdAddr = $0200
    devNum = %000
    slvAddr = EE24LC32 | (devNum << 1)
    addrLen = 2
    GOSUB Read_Byte
    
    


    On the previous page, there's an example of writing to a device. I've modified it slightly so it's for another 24LC32A, but with a device address of 1 instead of 0 (since that's how your "write socket" is connected).
    devNum = %001
    slvAddr = EE24LC32 | (devNum << 1)
    addrLen = 2
    GOSUB Write_Byte
    PAUSE 5
    
    


    The PAUSE is to allow the 24LC32A to finish its write cycle (it takes about 5ms). Note that the EEPROM address (in wrdAddr) is the same in both routines and that the value read with the first routine (i2cData) is used in the second routine to write to the EEPROM. All you have to do to copy the EEPROM is to put these two routines in a loop:
    for wrdAddr = 0 to 4095
    '  first routine
    '  second routine
    next
    
    


    I would suggest you also have a verify program that reads from a location in the first EEPROM, saves the value (i2cData) in another variable, then reads the same location in the second EEPROM (you should be able to figure out how to do that) and compares the two values and, if not equal, displays an error message and stops. If equal, go on to the next location until all are checked.
Sign In or Register to comment.