I2C Read timeout too long

Noelia_Moreno
Posts: 1
Joined: Fri Feb 18, 2022 2:12 pm

I2C Read timeout too long

Postby Noelia_Moreno » Fri Feb 18, 2022 2:23 pm

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.

squirtle321
Posts: 11
Joined: Tue Jan 11, 2022 9:26 pm

Re: I2C Read timeout too long

Postby squirtle321 » Thu Oct 13, 2022 9:30 pm

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

username
Posts: 479
Joined: Thu May 03, 2018 1:18 pm

Re: I2C Read timeout too long

Postby username » Sat Oct 15, 2022 3:04 pm

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

vadimus
Posts: 1
Joined: Sun Nov 27, 2022 7:21 pm

Re: I2C Read timeout too long

Postby vadimus » Sun Nov 27, 2022 7:24 pm

Also seeing this behavior. Could be related to this driver bug: https://github.com/espressif/esp-idf/issues/4999

Who is online

Users browsing this forum: Bing [Bot] and 125 guests