Page 1 of 1

I2C Read timeout too long

Posted: Fri Feb 18, 2022 2:23 pm
by Noelia_Moreno
We are using ESP-IDF version 4.3.2. and we are using the I2C comunication with LM75 sensor. In some cases this sensor is disabled and a I2C timeout should occur. Since this is in the main loop and we need a fast execution, the I2C timeout should be the minimun posible. We are observing that the timeout the comunication is 1 second every time.

This is the code we are using for read LM75 sensor. As you can see we have set a maximum wait of 10 ms in the i2c_master_cmd_begin function, but we are observing 1 second timeouts.

Code: Select all

esp_err_t ret;
i2c_cmd_handle_t cmd = i2c_cmd_link_create();

i2c_master_start(cmd);
i2c_master_write_byte(cmd, (addr_lm75 << 1 | I2C_MASTER_WRITE), I2C_MASTER_ACK);
i2c_master_write_byte(cmd, reg_lm75, I2C_MASTER_ACK);
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (addr_lm75 << 1 | I2C_MASTER_READ), I2C_MASTER_ACK);

if (length_lm75 > 1)
{
	i2c_master_read(cmd, val_lm75, length_lm75 - 1, I2C_MASTER_ACK);
}

i2c_master_read_byte(cmd, val_lm75 + length_lm75 - 1, I2C_MASTER_NACK);
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(I2C_NUM_0, cmd, pdMS_TO_TICKS(10));
i2c_cmd_link_delete(cmd);

return ret;
Thanks in advance.

Re: I2C Read timeout too long

Posted: Thu Oct 13, 2022 9:30 pm
by squirtle321
I'm also experiencing a similar issue. I have the timeout set to be very short (2 ticks), but I'm seeing a timeout of 1000 ticks.

I'm wondering if you found a solution for your issue?

Thanks

Re: I2C Read timeout too long

Posted: Sat Oct 15, 2022 3:04 pm
by username
Not sure if this is it or not. The examples show: ret = i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS);

Not sure if pdMS_TO_TICKS(10) results are the same as 10 / portTICK_RATE_MS

Re: I2C Read timeout too long

Posted: Sun Nov 27, 2022 7:24 pm
by vadimus
Also seeing this behavior. Could be related to this driver bug: https://github.com/espressif/esp-idf/issues/4999