Hello!
I'm working on a project where an esp32 devboard should be an i2c slave, answering to requests from a master device.
I noticed, as other users in the forum, that the order of requests and responses is wrong.
My protocol is very simple: master sends one byte, slave responds with one byte.
It's therefore very easy to find out that the response I'm sending to the master is received in the next loop.
I found that a user recently posted an issue on github:
https://github.com/espressif/arduino-esp32/issues/12467
the issue was posted in the Arduino core, but I suspect it's something related to the framework itself.
Are you aware of anything specific here? The documentation says that I should write to the buffer (i2c_slave_write) during the "on_request" callback, but it seems to me that it's too late: I was able to send the correct data if I move the command in the "on_receive" callback,, but only if the master doesn't make use of "repeated start" feature.
Unfortunately I don't own a logic analyzer to verify what's happening at the bus level.
AFAIK a slave should keep the SCL low (stretch) until it has some data to transmit, but in my examples it seems that this is not happening.
Thanks!
v6: i2c slave, wrong order in request-response
-
kurtzweber
- Posts: 66
- Joined: Tue Jan 10, 2017 1:09 pm
-
kurtzweber
- Posts: 66
- Joined: Tue Jan 10, 2017 1:09 pm
Re: v6: i2c slave, wrong order in request-response
found another post in this forum which seems to report my same issue:
viewtopic.php?t=42049
viewtopic.php?t=42049
Who is online
Users browsing this forum: Applebot, Baidu [Spider], PerplexityBot, Semrush [Bot] and 18 guests