Comments (2)
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.
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)
- WritePins always fails HOT 2
- Patch for /trunk/src/mpsse.i HOT 1
- make install command does not work at MinGW
- Failed to initialize MPSSE: device not found
- Erronous start condition if using GPIO on low bits in i2c mode
- pyswig versions of functions leaked into C library (libmpsse.a/.so)
- FastTransfer always fails
- Problems with the Setup
- How to address i2c slaves HOT 1
- I2C Read gives one bad bit, but only rarely
- SetDirection in MPSSE mode
- FIXED Apple OS X library compilation and installation with libftdi1 from MacPorts
- where is pylibmpsse ? HOT 1
- I2C eeprom python script available HOT 1
- Patch for /trunk/src/mpsse.c
- Different names of values in examples/spiflash.py
- i2c ACK bit not read properly
- trouble running spiflash -p (likely an install issue)
- SPI_ReadWrite returned unexpected result HOT 2
- open usb-serial port
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 libmpsse.