I2Cm Fault Tolerance | Cypress Semiconductor
I2Cm Fault Tolerance
I am using an application with a simple master (PSOC) and a slave device.
When I issue R/W commands to Slave, I accumulate the return values from the I2C API,
and then evaluate this for > 0 (errors), eg. looking for an error, to implement error handling.
If I disconnect clock or data line the I2Cm gets stuck in a I2Cm API, a function called clockstretch2.
So net effect is to take down entire application.
Code being used -
unsigned char I2Cok = 0;
I2Cok = ( I2Cm_fSendStart( SLAVADD, I2Cm_WRITE ) == 0 ) ? 1 : 0; // Send start bit
I2Cok = ( I2Cm_fWrite( memadr ) == 0 ) ? I2Cok + 1 : I2Cok; // Send command to read Tobject
I2Cok = ( I2Cm_fSendRepeatStart( SLAVADD, I2Cm_READ ) == 0 ) ? I2Cok + 1 : I2Cok; // Send repeat start bit
rxBuf[ 0 ] = I2Cm_bRead( I2Cm_ACKslave ); // Read low order byte
rxBuf[ 1 ] = I2Cm_bRead( I2Cm_ACKslave ); // Read high order byte
rxBuf[ 2 ] = I2Cm_bRead( I2Cm_ACKslave ); // Read PEC
Code works fine, until I disconnect a clock or data line to I2C slave, or if a loss of power to slave
occured. Clearly this should be considered a defect in I2C API implementation, inability to handle
a HW failure. I suppose a workaround would be watchdog, but that I think is a poor choice.
Is this also case for Creator ?