Giter Club home page Giter Club logo

Comments (2)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 15, 2024
After several days of hacking, testing, and observation with a logic analyzer, 
I've come up with a fix.

Background:
The Invensense MPU-9150 supports burst reads.  From their documentation:

"To read the internal MPU-9150 registers, the master sends a start condition, 
followed by the I2C address and
a write bit, and then the register address that is going to be read. Upon 
receiving the ACK signal from the
MPU-9150, the master transmits a start signal followed by the slave address and 
read bit. As a result, the
MPU-9150 sends an ACK signal and the data. The communication ends with a not 
acknowledge (NACK)
signal and a stop bit from master. The NACK condition is defined such that the 
SDA line remains high at the
9th clock cycle."

However, the LibMPSSE Read function leaves the SDA line in the last ACK state 
seen or as specified with SendAck or SendNack.  In order to bring the SDA line 
high for a proper Stop condition to be present on the pins, what we really need 
is to have the last byte read send a NACK but all previous bytes send an ACK.

The Fix:
In support.c, we modify line 185 as follows:

// Old way
buf[i++] = mpsse->tack;

// New way
if ( j == num_blocks-1 )
   buf[i++] = 0xFF;
else 
   buf[i++] = mpsse->tack;

This causes the last byte sent to put a NACK on the line.  Now perhaps in 
future versions this should be an option.  E.g Send the inverted acknowledge 
state.  It would probably depend on the device.

Original comment by [email protected] on 27 Sep 2013 at 4:19

from libmpsse.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 15, 2024
If you are just doing a single-byte read sequence, the following should work:

i2c.SendNacks()
i2c.Start()
data = i2c.Read(1)
i2c.Stop()

For multiple bytes where you want ACKs on all but the last byte, this should 
work:

i2c.SendAcks()           # Always send ACKs
i2c.Start()
data = i2c.Read(3)     # Read the first three bytes
i2c.SendNacks()         # From here on out, send NACKs
data += i2c.Read(1)  # Read the last byte
i2c.Stop()

Is this not the case? Regardless, your solution is probably more convenient as 
sending a NACK on the last byte read is a fairly common operation.

Original comment by [email protected] on 1 Oct 2013 at 7:11

from libmpsse.

Related Issues (20)

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.