How to detect I2C device exists

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
yaga_3967241
Level 3
Level 3
50 sign-ins 25 sign-ins 10 replies posted

Hello,

We are using PSoC LP5 and I2C component.

We have a case that I2C device may attach or disconnect. What is the best way to detect a I2C device is connected or disconnected?

Regards,

Winston

0 Likes
1 Solution

Hi @yaga_3967241 ,

No, when it comes to detecting a slave's attachment or detachment, both work the same way, i.e. you will have to poll the I2C line with the slave address for slave presence.
You could use an additional GPIO pin as a detect pin but this would require you to make some hardware changes on the slave if not already done.

Warm Regards
Alen

View solution in original post

0 Likes
4 Replies
AlenAn14
Moderator
Moderator
Moderator
500 replies posted 100 solutions authored 250 replies posted

HI @yaga_3967241 ,

Can you please let me know if you are using an SCB or UDB based I2C Component?
Also, If your I2C component is configured to be a master device, then it will have to poll the I2C lines at periodic time intervals of your choosing to detect if a slave device has been connected or disconnected since the I2C lines are pulled up to Vcc by default when no communication is ongoing. 
You will have to first perform a read of the slave using the API I2C_MasterReadBuf and then check for the value of I2C_MSTAT_ERR_ADDR_NAK in the return of the API I2C_MasterStatus(void) when using this polling method to detect if whether a slave is connected or not.

Please check the I2C component data sheet for code examples on how to use the above mentioned API's.

Warm Regards
Alen


yaga_3967241
Level 3
Level 3
50 sign-ins 25 sign-ins 10 replies posted

Hi Alen,

We are using UDB based I2C Component. Is there any difference between UDB based I2C component and SCB based I2C component as to detecting device existence?

Regards,

Winston

0 Likes

Hi @yaga_3967241 ,

No, when it comes to detecting a slave's attachment or detachment, both work the same way, i.e. you will have to poll the I2C line with the slave address for slave presence.
You could use an additional GPIO pin as a detect pin but this would require you to make some hardware changes on the slave if not already done.

Warm Regards
Alen

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I posted a couple of 5LP samples

https://community.infineon.com/t5/Code-Examples/MCU-Tester-a-Swiss-Army-Knife-for-PSoC-CY8CKIT-059-v...

https://community.infineon.com/t5/Code-Examples/MCU-Tester-a-Swiss-Army-Knife-for-PSoC-CY8CKIT-050-v...

In these samples, if you use command

I2C > Scan

The program will scan the I2C bus and report addresses of where devices were found.

moto

0 Likes