Replies: 2 comments
-
The SAMD51 and RP2040 have completely different I2C hardware blocks so low-level operations will be different between them. They're also being driven internally by massively different speeds of processor so race conditions which don't show up in one can appear in the other. There's also obviously setup/hold timing to verify. That said, since this needs some other HW and SW only you have, your best step is to see where the issue is manifesting. For example, after writing some series of registers, were they all written in the right spot? You can dump the register state in the |
Beta Was this translation helpful? Give feedback.
-
Thanks for the quick response @earlephilhower . Your suggestions helped me to find the root cause. The Wire.onRequest() call appears to be clearing the buffer on the RP2040 (it doesn't clear on the SAMD implementation). The workaround is very simple... just don't use the buffer when an I2C read cycle is detected... have the address stay at the same value from the write cycle's Wire.onReceive(). I am testing the fix on my SAMD and other MCU boards, to see if this implementation works for all my boards. Here is the fixed version (updated to support a 16bit address, 64k bytes):
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I wrote Arduino code to make a MCU appear as an I2C slave device with a 256 byte register map. This works great for SAMD MCUs, but the same .ino code does not work on RP2040. It looks like has to do with the Wire library buffer. The code below works for my Adafruit QT PY SAMD21 board (I do not need to explicitly define the SDA and SCL pins, they are in the board file). It also works fine on my Adafruit ItsyBits SAMD51 board.
I have tried this code on Pico and Xiao RP2040, and get identical results... slave ID is ACKed, but reading back written data is not at the expected address.
I'm using version 4.4.2 of your Raspberry Pi Pico/RP2040/RP2350 board library, and I use a RP2040 MicroPython I2C master (which drives the I2C master cycles identically for the SAMD slave). I have looked at the cycles with a logic analyzer and everything looks as expected.
Any ideas as to why the Pico handles the code below differently would be appreciated.
Thx
Beta Was this translation helpful? Give feedback.
All reactions