Comments (4)
Hey @Koepel, thanks for this! I'll push a fix.
I think you also win the honor of First Person Who Opened an Issue on a Personal Project for me :)
Out of curiosity, how'd you find my repo?
from samd21.
Google and the search function of Github: Are you using spider bot to scan Arduino libraries which misused the Wire library?
from samd21.
aha, nice
from samd21.
Excellent explanations but I want to mention that I had problems when reading from I2C. My first 2 Wire.requestFrom() would work and the following 2 had corrupt bits. If I commented out the first 2 Wire.requestFrom() then the following 2 would return valid data.
Then I came across an explanation in StackExchange that said I needed a delay(1) before requestFrom(), although it looks like perhaps only 1 clock cycle delay is needed and so could use
delayMicroseconds() say 20-50 microseconds (I need to calculate clock cycle time)
This is my working code with a delay(1). Without the delay as I mentioned I get corrupt data and a lot of headaches. And yes I could use Wire.requestFrom(I2C_ADDRESS, 2); but for checking I was only returning 1 byte at a time.
Perhaps this error is because I am requesting from different registry areas (VOUT_L) then (MFR_ID) between Wire.requestFrom() as the registry's are not concurrent?
So as you have the best explanation so far perhaps you might consider adding that a delay() or a timer interrupt might be needed before Wire.requestFrom().
Wire.beginTransmission(I2C_ADDRESS);
Wire.write(VOUT_L);
Wire.endTransmission(false);
delay(1);
Wire.requestFrom(I2C_ADDRESS, 1);
LSB_regByte = Wire.read();
Wire.requestFrom(I2C_ADDRESS, 1);
MSB_regByte = Wire.read();
Wire.beginTransmission(I2C_ADDRESS);
Wire.write(MFR_ID);
Wire.endTransmission();
delay(1);
Wire.requestFrom(I2C_ADDRESS, 1);
regByte = Wire.read();
Wire.requestFrom(I2C_ADDRESS, 1);
regByte2 = Wire.read();
from samd21.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from samd21.