- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Labels:
-
PSOC5 LP MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I posted a couple of 5LP samples
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