You can use the low level function fSendStart to check if a Slave ACKed the start condition and then use high level functions only if the slave was present. Following are the steps.
1. Use fSendStart and see if the Slave ACKs. If no ACK, send a Stop and release the bus
2. If Slave ACKs, send a stop to release the bus, re-enable the I2C interrupt (as fSendStart disables the I2C interrupt), and start using the high level API
Check out the project here.
Interfacing an I2C EEPROM to PSoC
This project shows a method to use the fSendStart function to poll if a slave is active on the bus before using a high level API.
The PSoC Hacker
Those are some good points to prevent stalling of the CPU when I2C is involved.
But I did face some issues when the software I2C module is used (I2Cm user module).
Specifically, any command after I2Cm_fSendStart is not executed.
Any thoughts on this anyone?
Can you please create a small project (preferably for a 29466) which creates that issue to have a look on it?
Think it would clarify what exactly doesn't work as you expect.
Would you happen to have a CY3240 and the little I2C slave board with you? I have a project for this hardware combination.
If not, I'll port to 29466 and post it.
No, no 3240 avail.
I have up to six slaves on a board and I would like to know which ones are present. I implemented the routine and code suggested above but every thing hangs up after the the master recieves an ACK from 4th slave and. The routine hangs in during the I2CHW_fSendStart for the 5th slave.
Any Ideas or help?
I have a similiar problem, using I2Cm module. If the slave clock or data
line is disconnected the firmware hangs in the clockstretch2 asm routine
the module uses. I have a Tech Case being looked at by Cypress. I will
pass on this thread to them.
Have you received any information back from cypress on solving this problem?
Yes, the SW team is going to, in the next release, date unknown, implement
a timeout function associated with the I2C clocking routines.
This will fix disconnected pins, SCL, SDA, pullups, from hanging main().
Hi Dana, I know that this is an old post but I seem to have a similar problem with the IIC bus hanging. It hangs in the
uint8 SensorIIC_MasterReadByte(uint8 acknNak) subroutine on the line while(SensorIIC_WAIT_BYTE_COMPLETE(SensorIIC_CSR_REG))
Do you know if the timeout function has been implemented yet?
Timeout has not been implemented, since I2C has no specification on the time limit.
I would like to point you to the discussion in this thread:
I have a similar problem and I've been looking through the include files. If you change this #define to 1, #define I2C_TIMEOUT_ENABLE (1u) then it compiles in this function: #if (I2C_TIMEOUT_ENABLED) I2C_TimeoutStop(); #endif /* End (I2C_TIMEOUT_ENABLED) */ which is undefined. Can't seem to find this in the docs, but I'm assuming we're meant to implement I2C_TimeoutStop for cleanup in our main? thanks, Johann
Johann, refer to the answer SAMP.CY gave: Timeout is not implemented.
On the other hand: A timeout would break the standards for I2C. A timeout was never defined in the protocol.
When a running connection dies and your code hangs in the I2C communication, you can reboot your machine (using WDT).