Skip to main content
KANTHA RAO BORA
Associate
March 31, 2018
Question

I2C same devices connected to MCU.

  • March 31, 2018
  • 5 replies
  • 1167 views
Posted on March 31, 2018 at 07:13

I want to connect 2 i2c devices of the same type(having same i2c slave address) to my MCU if I want to communicate with those devices which device is responding to master. How should I differentiate those same devices

    This topic has been closed for replies.

    5 replies

    Michal Dudka
    Lead
    March 31, 2018
    Posted on March 31, 2018 at 07:37

    You cannot connect two devices with identical slave address on I2C bus.

    First of all. Check if your device has inputs for 'user selectable address'. If it has, you can change slave addres to one of them ...

    If not, you can use two different I2C buses (STM usualy has plenty of them) or 'Bus switch' (like PCA9543) 

    M.
    Andrew Neil
    Super User
    March 31, 2018
    Posted on March 31, 2018 at 12:23

    dudka.michal.001 wrote:

    First of all. Check if your device has inputs for 'user selectable address'.

    Yes, that is the obvious first step!

    It would be a rather stupid I2C peripheral which did not provide some facility to adjust its Slave Address.

    Failing that, you could see if the device has some way to 'inhibit' its I2C interface; eg, take a look at 

    http://www.st.com/resource/en/application_note/dm00280486.pdf

      
    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
    Bogdan Golab
    Lead
    March 31, 2018
    Posted on March 31, 2018 at 11:52

    Apart from great solutions provided by

    Dudka.Michal

    you can use software based I2C solution (in case you lack of another I2C bus e.g. pins are already occupied for another purpose):

    http://download.mikroe.com/documents/compilers/mikroc/arm/help/software_i2c_library.htm

    S.Ma
    Principal
    March 31, 2018
    Posted on March 31, 2018 at 13:48

    You need to know very well your slave spec. 

    Think powering up the slave with MCU GPIO if feasible and unpowered slave keeps its I2C pins true open drain.

    You could also use other alternate function pins for the same I2C Cell to have like 2 buses from same HW I2C Cell.

    Actually in this case, just a different sda could be enough (sharing same clock line)

    jean-christophe Toussaint
    Associate III
    March 31, 2018
    Posted on March 31, 2018 at 15:54

    Hello

    Few months ago, the lack of documentation from the HAL Library forced me to develop a software I2C routines.

    Maybe the following link will help you.

    https://community.st.com/0D50X00009bMM7pSAG

     

    Best regards

    JC