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-06-2019 08:16 AM - edited 09-06-2019 08:53 AM
Please check with the following questions:
1) Is there any device besides BME280 in I2C bus?
2) Can ChipID correctly be read out?
3) Can you get I2C wave from initialization to normal & abnormal reading data?
09-06-2019 08:57 AM
Hi Shellywang,
1) There are: one EEPROM and two temperature sensors.
2) Yes, the bus works correctly for the most of the time
3) I can't verify that since the line are not accessible with an oscilloscope
Thank you
Walter
09-06-2019 12:53 PM
09-06-2019 03:43 PM
Yes, that's exactly what I'm doing now to recover the bus functionalities when it hangs up.
I was trying to understand why this happens to try to avoid it.