I have here a Problem with an I2C bus configuration, that runs in a timeout after a certain time. The I2C slave is a fujikura ap4/ag4 pressure sensor and the master a STM32F4. I read continiously the pressure and after around 5-10min, a timeout error occures and the HAL_I2C_Master_Receive always returns a timeout error after that. The error occures in the stm32f4xx_hal_i2c.c because the following routine falls into a HAL_TIMEOUT
/* Wait until ADDR flag is set */
if(I2C_WaitOnMasterAddressFlagUntilTimeout(hi2c, I2C_FLAG_ADDR, Timeout, Tickstart) != HAL_OK)
{
if(hi2c->ErrorCode == HAL_I2C_ERROR_AF)
{
return HAL_ERROR;
}
else
{
return HAL_TIMEOUT;
}
}
Edit: What I noticed is, that the I2C3->CR1->STOP is set before the HAL_I2C_Master_Receive call when it returns an error. When I then clear this flag a few times while debugging, the I2C recovers and runs then again, until the next, same error occurs.