Hi,
so using KSDK 1.1 and KDS 2.0.0. I also use Processor Expert for module configuration.
I was testin how well behave my code when something bad happens to the external I2C module (it's a Adafruit 10DOF) connected with a long cable.
So when I shorted SCL to ground the program just got stuck. CPU was still working but I2C communication stopped.
I2C is configured to use interrupts.
It seems that the program got stuck here (in ../SDK/platform/hal/src/i2c/fsl_i2c_hal.c)
bool I2C_HAL_WriteByteBlocking(uint32_t baseAddr, uint8_t byte)
{
#if FSL_FEATURE_I2C_HAS_DOUBLE_BUFFERING
while (!BR_I2C_S2_EMPTY(baseAddr))
{}
#endif
/* Write byte into I2C data register. */
HW_I2C_D_WR(baseAddr, byte);
/* Wait till byte transfer complete. */
while (!BR_I2C_S_IICIF(baseAddr) ) <<<<<<<< STUCK HERE!!!!!!
{}
/* Clear interrupt flag */
BW_I2C_S_IICIF(baseAddr, 0x1U);
/* Return 0 if no acknowledge is detected. */
return !BR_I2C_S_RXAK(baseAddr);
}
I also tried to put a timeout in the while, but then the program crashed with a failed assertion:
"assertion "BR_I2C_C1_MST(baseAddr) == 1" failed: file "../SDK/platform/hal/src/i2c/fsl_i2c_hal.c", line 253, function: I2C_HAL_SendStop"
Any ideas how to improve this? The program should be able to fucntion even if the I2C bus is not working
Thanks Best Regards
Giacomo
Edit: same thing happens if I short to ground the SDA line.