Shop OBEX P1 Docs P2 Docs Learn Events
i2c — Parallax Forums

i2c

AHMET AKSUAHMET AKSU Posts: 62
edited 2007-04-20 16:40 in Propeller 1
· is it possible to do that

·a have variable which name vra can I use·· @vra (which will return the address of a variable in RAM)·to write to the EEPROM at that same offset
and then when propeller restart update variable vra from eeprom

Comments

  • AHMET AKSUAHMET AKSU Posts: 62
    edited 2007-04-19 09:56
    also are there any one who knows abaut basic i2c driver writen by michael green.in the spin I want to use ReadLong and writelong metod. whats the scl and devsel.
    actually I m using 24lc512 on 28 29 pin of propeller.How can I use second 32 k byte part of eeeprom device for reading and writing long variable


    PUB ReadLong(SCL, devSel, addrReg) : data
    '' Read in a single long of i2c data. Device select code is devSel. Device
    '' starting address is addrReg. The device select code is modified using the
    '' upper 3 bits of the 19 bit addrReg. This returns true if an error occurred.
    '' Note that you can't distinguish between a return value of -1 and true error.
    if ReadPage(SCL, devSel, addrReg, @data, 4)
    return -1
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-19 11:26
    There is an example in the comments at the beginning that shows you the answer to your question.

    SCL is the pin number used as the clock pin for I2C. SDA is the next higher numbered pin. In your case, SCL should be 28.
    devSel is the device select or device address value to be used. For EEPROMs this is $A0. The routines automatically change
    this to $A2, $A4, ..., $AE for addresses greater than $FFFF and they automatically add the read/write bit (odd/even).

    To use the second 32K byte part, just use an address (addrReg) in the range $8000 to $FFFF.
  • AHMET AKSUAHMET AKSU Posts: 62
    edited 2007-04-19 13:07
    ··
    ···· Dear Mike Green

    · thanks for your answer.on my project there are only one 24lc512 .and a1,a2,a3 pins of it is connected to the graund .in this case what is the devsel value for me and what is the addrreg value for the starting point of second 32 kbyte .
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2007-04-20 01:40
    First, please read the comments in the beginning of the source code for the I2C routines. The information you need is there!

    As I said previously, the device select value is $A0 and the address range for the second 32K of the EEPROM is $8000 through $FFFF.
  • AHMET AKSUAHMET AKSU Posts: 62
    edited 2007-04-20 16:40
    thanks .I tried A0 and 8000 .its working good
Sign In or Register to comment.