fix(ulp): correct LP I2C interrupt wait cycle duration (IDFGH-17203)#18208
fix(ulp): correct LP I2C interrupt wait cycle duration (IDFGH-17203)#18208puyogo-suzuki wants to merge 1 commit intoespressif:masterfrom
Conversation
👋 Hello puyogo-suzuki, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
|
Hi @puyogo-suzuki |
|
sha=ea27268c7e613fce27210d810790af001afa6168 |
|
Will these changes work on non-RISCV based chips? |
|
This change only affects RISC-V based chips, as the codebase for Xtensa based chips is different. esp-idf/components/ulp/ulp_riscv/ulp_core/ulp_riscv_i2c.c Lines 70 to 75 in 97d9585 Because the |
|
Hi @safocl, @puyogo-suzuki |
|
Thanks 👍 |
I meant that it is generally present in the general file |
Description
This pull request updates the
lp_core_i2cmodule to improve how I2C interrupt wait timeouts are handled. The main change is switching from a software-based loop counter to using the RISC-VmcycleCSR for more accurate and robust cycle counting.mcycleCSR to measure elapsed cycles for timeouts inlp_core_i2c_wait_for_interrupt, improving accuracy and reliability.#include "riscv/csr.h"to access CSR functions.Related
None.
Testing
This is a test case repository: https://github.com/puyogo-suzuki/esp-lpi2c-timeout
I tested on ESP32-C6 with the latest ESP-IDF (master branch).
I connected Pin 6 (LPI2C SDA) to GND.
The expected behavior is that
lp_core_i2c_master_read_from_devicereturnsESP_ERR_TIMEOUTaftercycles_to_waitcycles.I measured the elapsed cycles by reading
mcycle.However, before this PR, the
resultwas approximately 30x longer thanLP_I2C_TRANS_TIMEOUT_CYCLES(= 150000).This PR improves the precision of the timeout.
resultwill be reduced to approx.5300, which is closer toLP_I2C_TRANS_TIMEOUT_CYCLES.Checklist
Before submitting a Pull Request, please ensure the following: