Nucleo STM32L432KC - Sporadic error when write to expander's port GPIO using HAL functions
Hi,
For a project I'm using Nucleo STM32L432KC and STM32CubeMX V1.17.0.
I'm using the same code template for differents project and it's the first time I get this kind of errors:
At some points, when writing to a GPIO of expander PCA9535DB, I have HAL_ERROR returned. This error occurs when in function HAL_I2C_Mem_Write (same error with HAL_I2C_Mem_Read) from stm32l4xx_hal_i2c.c file.
/* Process Locked */
__HAL_LOCK(hi2c);
/* Init tickstart for timeout management*/
tickstart = HAL_GetTick();
if (I2C_WaitOnFlagUntilTimeout(hi2c, I2C_FLAG_BUSY, SET, I2C_TIMEOUT_BUSY, tickstart) != HAL_OK)
{
return HAL_ERROR;
}Above the code that return the HAL_ERROR. (from file stm32l4xx_hal_i2c.c)
The fact is that the timeout is raised in I2C_WaitOnFlagUntilTimeout but I have no idea why.
As the code sometimes work and sometimes not, I assume that I2C address and parameters are correct. (Speed is 100KHz).
If someone already has the same behavior, help is welcome.
Best regards,
Antoine
