-
Notifications
You must be signed in to change notification settings - Fork 890
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
RP2040 I2C Target mode doubles first byte sent in Reply #4331
Comments
Upon further testing, it does appear to be something with my code; a much simplified i2c target works as expected. Will test a bit more and then close bug if that's the case. Works as expected:
|
Ah ha. If the reply is small, like 4 bytes in the above example, the doubling of the first byte problem doesn't show up. But a 10 byte reply does reproduce the issue. From reading the rp2040 datasheet and looking over the tinygo i2c code for the rp2040, I can't see why this would make a difference. The way *I2C.Reply() is written, it doesn't seem like it should matter how many bytes are sent back. |
Well after much fiddling around, I tried rewriting the Reply() method in machine_rp2040_i2c.go
And now I2C works as expected. Not sure what I did differently. I'm doing some further testing and if it seems good, I'll submit a PR for the fix. |
Reopening, will close on next release. |
I'm using a Raspberry Pi Pico as an I2C Target. The host is a Raspberry Pi Zero 2W.
After one transfer, the first byte is always doubled up.
On the Host (Pi Zero):
I have the Pico dumping output on USB serial. It shows the below, which is correct.
And here is a trace with a logic analyzer. The pico sends the first byte; pauses, then sends the first byte again along with the rest.
Any idea's what's going on here? I based my code on https://github.com/tinygo-org/tinygo/tree/release/src/examples/i2c-target
It seems like something's wrong with the Pico's I2C peripheral (or how it's configued, or how it's called, etc), or the code implementing Reply().
I have an http-like router for handling I2C r/w requests to registers. I've tried to pare down the code to just what's relevant. This seems to work fine but 🤷🏽 if it's related to the issue I'm seeing.
The text was updated successfully, but these errors were encountered: