ESP32-S3 I2C master time-out

Bryght-Richard
Posts: 44
Joined: Thu Feb 22, 2024 3:59 pm

ESP32-S3 I2C master time-out

Postby Bryght-Richard » Wed May 29, 2024 9:33 pm

I'm trying to refine my understanding of how the ESP32-S3 master-mode I2C time-out is applied. I'm working with an I2C battery fuel-gauge that can clock-stretch for up to 4 milliseconds. We also have an I2C touch-screen. Rarely, I2C accesses to the fuel-gauge will time out. So I thought I would extend the ESP32-S3 timeout to see if that fixes it.

I found this in the ESP32-S3 TRM:
I2C_TIME_OUT_VALUE This field is used to configure the timeout value for receiving a data bit in I2C_SCLK clock cycles. The configured timeout value equals 2^I2C_TIME_OUT_VALUE clock cycles. (R/W)
But the ESP-IDF says:
esp_err_ti2c_set_timeout(i2c_port_ti2c_num, int timeout)
timeout: timeout value for I2C bus (unit: APB 80Mhz clock cycle)
.

Based on adjusting the timeout, I think the timeout value is actually (2^I2C_TIME_OUT_VALUE) APB cycles. Does that sound right?

Bryght-Richard
Posts: 44
Joined: Thu Feb 22, 2024 3:59 pm

Re: ESP32-S3 I2C master time-out

Postby Bryght-Richard » Thu Jun 06, 2024 3:16 pm

It seems the answer is that it depends

esp_err_ti2c_set_timeout() will check the parameter boundaries and assign it to the register, but the register encoding seems to depend on the specific chip. The ESP32-S3 uses the power-of-two method, but some other ESP32 family devices have a much wider register that could be a plain linear encoded number.

Who is online

Users browsing this forum: No registered users and 69 guests