Shop OBEX P1 Docs P2 Docs Learn Events
24FC512 using I2C W/BS2p code sample? — Parallax Forums

24FC512 using I2C W/BS2p code sample?

JonathanJonathan Posts: 1,023
edited 2004-10-29 17:11 in BASIC Stamp
Hi All,

I really did give it a college try, but I couldn't find an example of using the 24FC512 eeprom using the I2C commands with a BS2p. Anyone know of a code snip? I tried using the forum search and digging through my stash of the old e-mail forum, but couldn't find anything. I was sure I had seen mention of it· somewhere though...

Thanks!

Jonathan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot

Comments

  • cyberbiotacyberbiota Posts: 79
    edited 2004-10-28 21:30
    Jonathan-

    Parallax published an app note for the xicor X25640 8K EEPROM.· It shows the hookup for the·spi bus to the chip, as well as lots of code.· Search for the part, and then download the datasheet/appkit pdf.·

    peter

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Peter C. Charles

    Director, Research and Technology
    CyberBiota, Incorporated
    Peter.charles@cyberbiota.com
    http://www.cyberbiota.com
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-10-28 21:35
    It looks like it should be pretty simple; something like this:

    device   VAR  Nib
    slave    VAR  Byte
    address  VAR  Word
     
    ...
     
    slave = %10100000 | device
    I2COUT SDA, slave, address.BYTE1\address.BYTE0, [noparse][[/noparse]data ...]
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • JonathanJonathan Posts: 1,023
    edited 2004-10-28 22:10
    Jon,

    That got me started, but it still isn't working right. using this code:

    address VAR Word
    result VAR Word
    main:
    FOR address = 0 TO 9
    I2COUT 0,$A0,address.BYTE1\address.BYTE0,[noparse][[/noparse]address]
    NEXT
    FOR address = 0 TO 9
    I2CIN 0,$A0,address.BYTE1\address.BYTE0,[noparse][[/noparse]result]
    DEBUG DEC result, CR
    NEXT
    PAUSE 1000
    GOTO main

    The program debugs the numbers 1-9 correctly, but 0 is always a 255 instead. It can run up to 254 with the same error. How would I address the eeprom above 65534? I have been poring over the data sheet and docs, and I think I'm missing a vital point or two somewhere.

    Peter, I'm going to go look at that article now.

    Many thanks,

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
  • cyberbiotacyberbiota Posts: 79
    edited 2004-10-28 22:41
    Jonathan-

    My apologies- the app note is for an SPI device (all I ever use).· It isn't likely to be much use to you.· Sorry.

    peter

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Peter C. Charles

    Director, Research and Technology
    CyberBiota, Incorporated
    Peter.charles@cyberbiota.com
    http://www.cyberbiota.com
  • JavalinJavalin Posts: 892
    edited 2004-10-29 14:05
    Im sure I've seen (but cannot find at present) a Nuts & Volts columns for the microchip's 24Lxxxx series I2C EEPROM which should cover the technique. These are freely downloadable from www.parallax.com

    James
  • cyberbiotacyberbiota Posts: 79
    edited 2004-10-29 14:18
    Jonathan-

    Try the stamp works app note 32:

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

    It covers I2C coms with Microchip eeproms.

    peter

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Peter C. Charles

    Director, Research and Technology
    CyberBiota, Incorporated
    Peter.charles@cyberbiota.com
    http://www.cyberbiota.com
  • JonathanJonathan Posts: 1,023
    edited 2004-10-29 15:22
    All,

    The Stampworks #32 doesn't use the I2C commands, which I had hoped to use. Why? Just because they are there. I guess I will try the SW #32 code and see if I can get to work. However, I am so close with the I2C commands. All I need to do is figure out how to address the memory above space 254.

    James, I too thought there was a N&V column about eeproms and I2C, but I couldn't find it and Jon didn't mention it, so I guess there isn't.

    Thanks for all the help!

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-10-29 15:52
    My current N&V column has to do with I2C -- but it's for the BS2, BS2e, and BS2sx; controllers that don't have built-in I2C commands.· The biggest EE I have is a 24LC256 and I've never had any problems addressing all of it's cells (though the test program I wrote takes forever to run....).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • JonathanJonathan Posts: 1,023
    edited 2004-10-29 16:39
    I have figured out that the problem is not my addressing of the memory, but how I read/write word sized data. I can write to all of the memory, I just can't break a word into two bytes and store and retrive it. I have tried every configuration of the code below that I can think of. There must be a major and simple DUH that I am pulling!

    address VAR Word
    result VAR Word
    dat VAR Word
    address = 0
    dat = 17

    I2COUT 0,$A0,address.BYTE1\address.BYTE0,[noparse][[/noparse]dat.Byte1]
    address = address + 1
    I2COUT 0,$A0,address.BYTE1\address.BYTE0,[noparse][[/noparse]dat.Byte0]

    address = 0
    I2CIN 0,$A1,address.BYTE1\address.BYTE0,[noparse][[/noparse]result.BYTE1]
    address = address + 1
    I2CIN 0,$A1,address.BYTE1\address.BYTE0,[noparse][[/noparse]result.BYTE0]
    DEBUG DEC result, CR

    END

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
  • JonathanJonathan Posts: 1,023
    edited 2004-10-29 16:46
    Aha!! I had forgot to put a 10mS pause in between reads/writes !! Somedays I wish I'd been born just a hair smarter...

    Thanks for all the help folks!

    Jonathan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-10-29 17:11
    I2C devices are byte oriented, and automatically update their address on each write. You can do this:

    FOR address = 0 TO $FFFF STEP 2
    · I2COUT SDA, $A1, address.BYTE1\address.BYTE0, [noparse][[/noparse]value.BYTE0, value.BYTE1]
    · ...
    NEXT

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
Sign In or Register to comment.