-
Notifications
You must be signed in to change notification settings - Fork 7.6k
I2C wrong callback order on repeated start command #6793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@me-no-dev PTAL, thanks. |
Resolution is rather simple. Do not use repeated start :) |
I just thought it's a better soulution rather than 2 separate requests :) Because I've spend a lot of time researching this issue and I saw that there are some i2c slave devices that working with repeated start |
It is ESP related "problem" when both devices are ESPs. Catching the repeated start as Slave is rather complicated and that coupled with the way that the master sends the transaction could get you in such situation. Using separate write and read transactions (not calling |
Thanks, @me-no-dev ! Closing this issue |
Hi, I have exactly the same problem. Basically, after writing to slave, master always receive previous result. I debugged using serial output on the slave's side and everything seems to be in correct order but master always receive previous "requestFrom" result. Is this not fixed? I used Wire.endTransmission() and tried both requestFrom(I2C_DEV_ADDR, 2) and requestFrom(I2C_DEV_ADDR, 2, true) without success. So frustrated, I hope someone can shed some lights. |
Also in my case, I did write and read from master twice consecutively and it seems that the slave haven't finish preparing the data on the second request and I received partly "⸮⸮⸮⸮⸮" jibberish data. Adding delay(1000) in between each write read sequence seems to fix the issue although the order of result is still incorrect as described above. Is there an elegant way for Master device to properly wait until slave is ready instead of predicting the processing time using delay? |
Hi @albertlt! |
Hi. Both are esp32
Sent from Yahoo Mail for iPhone
On Monday, July 11, 2022, 20:59, YehorFedorov ***@***.***> wrote:
Hi @albertlt!
What boards do you use for master and slave?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@albertlt I think this is an answer to you question - #6677 (comment) I can't explain you the difference between esp32, c3, s2 and s3 chip and why this is an issue but I saw some comments that i2c slave mode don't work well or as we expect on esp32 chip but on newest chips like s2, s3 and c3 it works fine |
I used: "esptool.py chip_id" and found out the master is: ESP32-D0WDQ6-V3 (revision 3) and slave is: ESP32-PICO-D4 (revision 1). Are they affected by the issue that you mentioned? |
By the way, is there any method in Wire to clear everything in it's buffer? I tried Wire.flush() on slave at the end of each session but it doesn't seem to work as it still gave me the previous result every time I start a new request from master. |
The flow of my program is as follow:
Several minutes later, master send cmd 2 with expected result = "def" but I still get "abc" even though strResult was already cleared at the end of previous iteration. It seems that "previous result" was still stored somewhere in the Wire library. I'd like to clear it if possible. |
hello hi i am also facing same issue can you please let me know whether you have got any solution |
Board
ESP32 C3
Device Description
ESPRESSIF ESP32 C3 mini 1
Hardware Configuration
GPIO 5 - SDA
GPIO 6 - SCL
Version
v2.0.3
IDE Name
Arduino IDE
Operating System
macOS Big Sur v 11.6.5
Flash frequency
80 Mhz
PSRAM enabled
no
Upload speed
460800
Description
I'm trying to establish communication via i2c between 2 esp32 c3 devices. The idea is simple, I want to send non stop request to slave (with repeated start), where master write 2 bytes first and read data from slave. And it's working somehow but not in the way I expected because slave firstly run onRequest callback and then onReceive. This looks like a bug for me (correct me if I'm wrong)
As a result I'm receiving data from previous request...
Attaching my wiring and logic analyzer data for 2 requests



Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: