cancel
Showing results for 
Search instead for 
Did you mean: 

I2C same devices connected to MCU.

KANTHA RAO BORA
Associate II
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

5 REPLIES 5
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.
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
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)

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

  
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