-
Notifications
You must be signed in to change notification settings - Fork 14
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
myMem.begin() returns False if called immediately after a Write operation? #31
Comments
This is expected behavior. begin() will return false when isConnected() is false. isConnected will return false when the device does not ack an I2C query. The device does not ack I2C queries when it is busy. The device is busy when it's writing to EEPROM. Therefore, begin() will return false for a few ms while the write completes. This is by design. Writes take time. Rather than block during the write, we initiate the write and pass control back to the main code. When another write is initiated, the library checks to see if a write is in process. If it is, we block until the previous write is complete before starting another. begin() only needs to be called once at the start of your sketch. You can call isBusy() instead to test if a write is complete. |
Thank you for the explanation, this makes sense. I'm just not sure why I never experienced this behaviour before in previous releases? (nothing has changed in my projects since then). As for only calling begin() once at the start of my sketch: - |
You can call isBusy() instead to test if a write is complete. You can call isConnected() to see if the device acks (isBusy calls isConnected). |
Hi mate, can you please clarify the following?
|
I can't really answer this. read() is blocking and very fast. I can't think of a way that you could run the isBusy() during a read() without running your own low-level I2C operations.
Have a look. Two library variables are set, then isConnected is tested. While begin() doesn't do much more than isConnected(), I consider it bad practice to instruct users to run begin() multiple times.
Yes. Don't shy away from reading the manual my friend. |
Hi all, I'm hoping to quosh another issue I've been experiencing since v3.1.0 (or thereabouts).
I'm running the SparkFun Qwiic EEPROM Breakout - 512Kbit (https://www.sparkfun.com/products/18355).
With library versions prior to v3.1.0, if you called myMem.begin() immediately after completing a write operation it would always return True.
Now with the more recent releases (including the latest v3.2.2) if you call myMem.begin() immediately after completing a write operation, it continues to return false for about 2-3ms... after which it then finally returns True.
Below is an example sketch which reproduces the issue:
Serial output:
Any ideas on why this may be happening with the more recent releases?
The text was updated successfully, but these errors were encountered: