GithubHelp home page GithubHelp logo

Comments (4)

aswild avatar aswild commented on July 17, 2024

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.

Koepel avatar Koepel commented on July 17, 2024

Google and the search function of Github: Are you using spider bot to scan Arduino libraries which misused the Wire library?

from samd21.

aswild avatar aswild commented on July 17, 2024

aha, nice

from samd21.

buccaneer-jak avatar buccaneer-jak commented on July 17, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.