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.

TM4C1231H6PM: How to implement the I2C switch

Part Number: TM4C1231H6PM


Hi ,

Please share code reference to implement  I2C switch logic to support .

Master I2C --------- TM4C I2C 0 ---------------------------I2C1 SLAVE 1

                                                            |----------------I2C 2 SLAVE 2

                                                            |----------------I2C 3 SLAVE 3

Reference code ./ Reference document 

Regards

Raghavendra 

  • While there are some I2C master and slave examples in the TivaWare library, I do not have an example of an I2C switch.
  • Raghavendra B C said:
    code reference to implement  I2C switch logic to support ... (up to 3 - I2C Slaves)

    Is not I2C intended as a,  "Common Bus, Multiple Device, System Interconnect?"      

    If agreed - then your "Accommodation of/to multiple I2C Slaves" - demands:

    • SDA be routed in parallel - from MCU (master) to each Slave  
    • SCL be treated similarly
    • Independent "Chip Selects" - generated by individual MCU GPIO - routed uniquely to each Slave's chip select.    
    • As the (normal) "FSS" pin under SPI is NOT used - you must create simple GPIO code to insure that,  "One and only one" SPI Slave is addressed - via management of the 3 GPIO outputs - serving as Slave I2C Chip Selects

    While the MCU manual "teases" re: internal pull-up resistors - firm/I consistently find that EXTERNAL Resistors (w/in the 4K7 - 10K range) prove far more robust & effective.    Applied to SDA & SCL.

    It should prove a "quick/eased SEARCH" for you to find a code example revealing I2C transaction w/a Single Slave.    To extend such to "multiple Slaves" - you would remove the FSS connection - and Add software to uniquely address, One I2C Slave at a time.    (via use of multiple GPIO pins - tied to the CS pin of each Slave.)    (proves harder to describe here - than to write the code - AND (some) User Effort IS required!)

    While there (may) exist several,  "I2C Channel Extenders" (also accommodating multiple Slaves) you've made "No case whatsoever" for their use - and you've simply, "SHIFTED" your design complexity - from the "EASE" described herein - to the "special demands" imposed by the I2C Channel Extender - which remain UNKNOWN.     As NO CLEAR advantage has been realized - one questions the value of such choice - "IF that was (even) your desire."

  • What's the point of your doing this? What do you expect it to do for you that couldn't have been done by the regular i2c?
  • Hi,

    We have Master MPU which connected to MCU via I2C0 Interface ,from MCU (tiva) we connected 3 slave devices to perform the read/write commands from I2C interface .

    There are few GPIO pins connected to few control functions from MCU to Slave devices.

    Regards
    Raghavendra
  • those slave devices have the same address?
  • Hi,

    The requirement is to connect to 2 similar address slave devices .

    I2C2 ---- SLAVE 1 <address 1>

    I2C3 ---- SLAVE 2 <address 1>

    Regards

    Raghavendra B C

  • what does your "similar" mean?

    you made helping you so much difficult.
  • The lack of clarity & precision has been apparent - from the outset...
  • Hi ,

    We are connecting 2 slave ,that slave address is same .

    MCU   I2C2 ------------- SLAVE 1 (ADDRESS = 0X0A)

    MCU  I2C3  ------------- SLAVE 2 (ADDRESS = 0X0A)

    Regards

    Raghavendra BC

  • To my read - this is the first time your requirement has been (properly) detailed.

    There exist external I2C devices (I'm unsure if they are classed as "switches") which perform EXACTLY as you desire. (i.e. these devices have the capability to accept the I2C bus signals from the master - and perform a programmable, "Modification of the I2C Slave's Address" - so that, "Two identically addressed" I2C Slaves may be, "uniquely accessed!")

    I encountered such an I2C "Bus Modifier" w/in the past few weeks (possibly after reading your post) - I'd have to search my notes to determine the maker & part number.

    Prior to the development of such, "I2C Bus Address Modifiers" we employed simple Data multiplexers - which enabled routing the I2C bus signals - to "One of N" I2C Slaves. Often this required adding another signal connection - not part of the I2C bus. The presence of this signal indicated that the "minority usage I2C device - sought to become - or was (ordered) Active - by the MCU.

    Many I2C devices provide 2-3 address pins - such that "4 or 8 devices" - may peacefully coexist...
  • Comes now my listing of pertinent, "I2C Address Translators" - which specifically address - your choice (and use) of  identically addressed - I2C devices.      

    It should be noted that often - when such, "One and only one" I2C address is provided - several such devices are offered.    (each one w/a different I2C address - designated by (usually) a special suffix w/in the part number.      This "escapes" the problem you've presented...)

    Another point - should those, "Part Variants" - each w/different I2C addresses - "NOT be provided" - one is left to conclude that the I2C vendor, "Did not anticipate the "integration" -  of  "multiple" such devices!"     Your usage then - appears to be "outside" of their "predictive capabilities."      (which may signal "your usage" to be "inspired" or (pardon) unwise/mistaken...)

    Following that (background) preamble - here are my firm's findings of  "Active/Available, I2C Address Translators" (able to resolve "identical I2C address" conflicts):   (exactly as you present)

    • LTC4316, LTC4317, LTC4318
    • MAX7356

    You must insure that these devices prove suitable for your usage.    (i.e. with a 3V3 I/O MCU)

    We are curious as to the identity of,  "Your I2C device" - which must be used in multiple - and such (multiple) usage has been "missed" by the manufacturer...