-
Notifications
You must be signed in to change notification settings - Fork 8k
Open
Labels
Status: OpenedIssue is newIssue is new
Description
Answers checklist.
- I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
- I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
- I have searched the issue tracker for a similar issue and not found a similar issue.
General issue report
This is with ESP-IDF 5.5.1, using the new I2C driver.
- When
i2c_master_bus_add_device(...)is called, it sets thescl_wait_usfield ini2c_master_dev_tusing the value from the inputi2c_device_config_tstruct, without performing any checks. - When
s_i2c_transaction_start(...)is later called,i2c_hal_master_set_scl_timeout_val(...)is then called with the value fromscl_wait_uswithout any checks. i2c_hal_master_set_scl_timeout_val(...)then callsi2c_ll_calculate_timeout_us_to_reg_val(...)andi2c_ll_set_tout(...)without any checks.i2c_ll_calculate_timeout_us_to_reg_val(...)computes a number of APB clock cycles, returning a 32-bit integer.i2c_ll_set_tout(...)then takes that 32-bit integer, and writes it to a 20-bit registertoutfor the I2C device. If the result overflows that field, it will be truncated and an incorrect smaller value will be used instead.
This limitation is not mentioned in any documentation around that field, so it could lead to confusion or selection of an unexpected timeout value.
Metadata
Metadata
Assignees
Labels
Status: OpenedIssue is newIssue is new