You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a peripheral (that I'm also in control of) connected to a Pi Zero 2 over I2C; only sending bytes from the Pi. I have clock stretching enabled in the peripheral so that when I get to a fairly rapid rate of transfer, the peripheral can hold the clock line low until it's ready for more.
However, in the i2cmaster.cpp code, the ERR flag is checked on the S (status) register first, which then returns from CI2CMaster::Write() as if a NACK had occurred. Only after that code is the CLKT flag checked.
The problem is that in my testing, both flags are set during a clock stretch, so an error is triggered first and the clock stretch result is never triggered. I can rearrange the if loop conditions and reliably get a clock stretch return value (where I have also confirmed the error flag set).
I'm curious if there's any historical reasoning here? I do see cd22971 with reference to class CI2CMaster works now similar to bcm2835 I2C library.
The text was updated successfully, but these errors were encountered:
The I2C master driver in Circle has been ported from Mike McCauley's bcm2835 library. The previous implementation was done on my own and had multiple issues.
According to this hardware errata page I2C clock stretching is not reliable on write and does work on read only on specific conditions in the Raspberry Pi's SoC. I cannot say, if clock stretching could be used at all for your specific purpose with the RPi Zero 2.
If it would help to rearrange the checks of the status conditions (ERR, CLKT) after the transfer, this could be changed in the Circle driver. Please let me know, if this would help you.
Thanks, I was more inquiring for info to start. Now that I look at bmc2835, I do see the similarity. Thank you also for the errata link. For now, I will continue testing, but I will come back here to either request that change or close this issue out soon.
After more testing, based on some of the unrelated intricacies of my setup, this doesn't make a practical difference. So things are fine in the project as is. Thanks again.
I have a peripheral (that I'm also in control of) connected to a Pi Zero 2 over I2C; only sending bytes from the Pi. I have clock stretching enabled in the peripheral so that when I get to a fairly rapid rate of transfer, the peripheral can hold the clock line low until it's ready for more.
However, in the
i2cmaster.cppcode, theERRflag is checked on theS(status) register first, which then returns fromCI2CMaster::Write()as if aNACKhad occurred. Only after that code is theCLKTflag checked.The problem is that in my testing, both flags are set during a clock stretch, so an error is triggered first and the clock stretch result is never triggered. I can rearrange the
ifloop conditions and reliably get a clock stretch return value (where I have also confirmed the error flag set).I'm curious if there's any historical reasoning here? I do see cd22971 with reference to
class CI2CMaster works now similar to bcm2835 I2C library.The text was updated successfully, but these errors were encountered: