09-04-2019 05:52 PM
Hi all,
I'm using a BME280 sensor on I2C bus with a STM32F072 mcu.
The sensor works as expected, but randomly the I2C bus gets frozen in BUSY state and the sensor is not accessible anymore.
Is there any advice for this kind of problem?
This is my I2C configuration:
/* I2C1 init function */
void MX_I2C1_Init(void)
{
hi2c1.Instance = I2C1;
hi2c1.Init.Timing = 0x00300208;
hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
{
Error_Handler();
}
/** Configure Analogue filter
*/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
{
Error_Handler();
}
/** Configure Digital filter
*/
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
{
Error_Handler();
}
}
Thank you
Walter
09-12-2019 10:11 PM
Can you keep just host and our BME280, then repeat the testing to see if the problem is still there?
09-25-2019 06:36 PM
We finally found one of the possible causes of the problem.
Analyzing the SDA and SCL signals with an oscilloscope we noticed that the rise time of both signals was near to 600 nsec.
Changing the pullup resistors from 4.7K to 1.0K we have better signals (very deep borders) with a raise time below 200 nsec.
The communication is more stable and the very few bus frozen situations can be recovered with the I2C reset procedure.