This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

8-bit I2C address?



Hi all,

I'm working with the F28335 on the eZdsp dev board.  I'm trying to interface with a gyroscope that works over I2C.  My problem is that the gyro wants its slave address, followed by a read/write bit, so essentially an 8-bit address all at once.  I can't see how to make this work using the registers on the 28335.  Anyone have an idea how to work around this?

Thanks a ton for your help!

  • Have you already seen sprug03? It seems that your mode should be supported, 7 bit address and afterwards the r/w bit. See chapter 2.5.1, "7-Bit Addressing Format".

    Regards,
    Joern.

  • Yup, you're right.  I'm unfamiliar with the protocol and just assumed the R/W bit was something only the sensor I was working with needed.  Thanks so much for straightening that out!

  • You're welcome. And to switch between read and write accesses to your device you get the r/w bit set indirectly via the mode you've chosen before, see chapter 2.3 "Operating Modes", master-transmitter vs. master-receiver... but I guess, you've found that already youself.

    Regards,
    Joern.

  • Right!  I was setting the I2C mode register correctly, I just didn't realize that the R/W bit was automatically taken care of.  Was just trying to make things harder for myself I guess... 

  • First, please forgive my poor english.I am using DS1388 about RTC,it have 8-bit slave byte and bit 0 is R/W.

    But I2C module just have 7-Bit Addressing Format or 10-Bit Addressing Format.So where can I set R/W bit??? i did not find any bit in such registers.

    If  i choose one of  four Operating Modes of the I2C Module,R/W bit will automaticlly be sent ???Is this understanding is right?

    I really need your help and can you offer me some examples about I2C module includes RTC like DS1388?

    Thanks very much!!!

    Regards,

    Yang

  • As far as from this data sheet I can see (bottom of page 16): the DS1388 has a 7-bit address as usual, and the lowest bit decides between R/W. The seven address bits (without the R/W-bit) of your I2C slave are the bits to be set within the I2C Slave Address Register (I2CSAR) of your I2C master (assuming it is one of the devices sprug03 stands for). As already discussed within this thread, the R/W bit will be sent concerning the chosen mode.

    Concerning source code: looks like if here was an example at least concerning the DS1388 - of course you would have to change that concerning your I2C master. Start with simple access to some read-only registers of your master, read carefully the manual, then try to accress some I2C read registers of your slave to check if this works and to become familiar with the devices and their registers. Also maybe it helpsto look around here within the forum (f.e. see this thread). Maybe also the I2C Tips are helpful for you, although written for C6000 devices.

    Regards,
    Joern.

  • Thanks,you are a kind-hearted man,I understand the issue.I just want to know whether the R/W bit is automaticlly sent if I choose one mode?

    But I still have some problems about when i see the I2C-EEPROM example.

    What is the difference between I2C_SLAVE_ADDR and I2C_EEPROM_ADDR ?? There is a sentence "This program requires an external I2C EEPROM connected to the I2C bus at address 0x50." in the example.Does it mean the slave address is the I2C EEPROM address?(ofcourse the I2C module is working on master transmiter or master receiver mode ).The code proves that my ideas is wrong!!!

    So what is the differences???

  • Thanks,you are a kind-hearted man,I understand the issue.I just want to know whether the R/W bit is automaticlly sent if I choose one mode?

    But I still have some problems about when i see the I2C-EEPROM example.

    What is the difference between I2C_SLAVE_ADDR and I2C_EEPROM_ADDR ?? There is a sentence "This program requires an external I2C EEPROM connected to the I2C bus at address 0x50." in the example.Does it mean the slave address is the I2C EEPROM address?(ofcourse the I2C module is working on master transmiter or master receiver mode ).The code proves that my ideas is wrong!!!

    So what are the differences???

  • It would help to know which of the samples you've in mind, best give a short code sample if concerning questions remain (that makes answering easier).

    At least the sentence "This program requires an external I2C EEPROM connected to the I2C bus at address 0x50." lets us know, that the concerning example obviously is written to access an EEPROM, which is connected to the I2C bus. And as it has to have an address there (0x50), it should be sure that it is intended to be used as I2C slave (what's the usual thing for EEPROMS connected to I2C) - because I2C always has ONE master (which thatswhy does not need to be addressed and does not have an I2C address) and one ore more slaves (which need to be addressed by the I2C master, to let them all know who of these slaves currently is wanted for reading from or writing to).

    So despite of what there is written and how it is named, an I2C address always is a slave address to distinguish between the slave devices being connected to an I2C bus.

    You only will have to be carefully to distinguish between the one I2C bus address of a slave and between the register addresses this slave may have inside to control it - these are no I2C addresses of course, but kind of subaddresses.

    And of course, concerning your RTC device, you will have to change the example to access the device you have instead of the example-EEPROM...

    Regards,
    Joern.

  • Thank you for your help!The example is about I2C module of c2000 and AT24C series EEPROM chip(i use DS1388).

    The I2C address always is a slave address to distinguish between the slave devices being connected to an I2C bus.This is easy to understand!

    but I dont understand this sentence  "between the register addresses this slave may have inside to control it - these are no I2C addresses of course, but kind of subaddresses. "

    If I understand like this the EEPROM address means the first address of the chip(memory unit where to write)??Is this understanding is right??

    When sending address,the example code first sends slave address,then sends eeprom address,but in the I2C Module 7-Bit Addressing Format,the second byte is data!So what code do means the second data byte is eeprom address.

    Thanks a lot for your help!I am interested in TI.

  • Technically, anything sent after the I2C slave address is considered "data" in that you need to write it to the I2C data transmit register (I2CDXR).  However, with many slaves, when reading or writing you first have to specify which register (on the slave) you would like to read from or write to.  In the case of the EEPROM example, each location on the EEPROM has a 16-bit address, so you must write that out (in 2 separate bytes) on the I2C bus first.  I am not sure exactly how the EEPROM in the example works, but I imagine the protocol looks something like this:

    To read from EEPROM:

    - Master sends start bit (handled automatically)

    - Master sends slave address + R/W bit (the R/W bit is handled automatically, the slave address is pulled from the slave address register, I2CSAR).  In this case you need to do a write.

    - Slave acknowledges.

    - Master sends first byte of EEPROM address of desired read.

    - Slave acknowledges.

    - Master sends second byte of EEPROM address of desired read.

    - Slave acknowledges.

    - Master sends another start bit (repeated start).

    - Master sends slave address + R/W (this time we are reading).

    - Slave acknowledges.

    - Slave sends first byte of data from address written above.

    - Master acknowledges.

    - Slave continues to send one byte of data at a time until master does not acknowledge (NACK condition).  Thus, the master must know how many bytes it is expecting (written in register I2CCNT, I believe).

    - Master sends stop bit.

    END

    If you are using the I2C module in FIFO mode, you can write all your "data" to I2CDXR, and then after appropriately setting I2CCNT everything will be sent out properly.  Similarly, you will be able to read I2CDRR (data receive register) until you have read out a number of bytes equal to I2CCNT.

    I hope this helps.  I was very confused about all of this myself not too long ago, so I understand where you are coming from.

  • I am sorry to my poor english.

    Now I really know about the procedures.Thank you a lot and thank everyone helps me! 

    This community is very good because of many members and engineers!

    You just said that  you know where i am from??? haha...

    I am glad to know your answer!

    And  I am glad to be friend with you !