Jump to content
I2Cdevlib Forums

Arduino Wire endTransmission readBytes not working


Recommended Posts

Hi,

in readBytes() in I2Cdev.cpp the register to read from is written and then before reading the actual value a new transmission is started.

This is not working for the MPR121.

 

Currently it does this:

Wire.beginTransmission(devAddr);
Wire.write(regAddr);
Wire.endTransmission();
Wire.beginTransmission(devAddr);
Wire.requestFrom(devAddr, (uint8_t)min(length - k, BUFFER_LENGTH));

Here is explained that the endTransmission is needed to actually send the regAddr.

But this is not working for the MPR121 because I guess it forgets the register you want to read from when the transmission is closed.

So on the request it always answers with the content of register 0x00.

So obviously all the mpr functions to read from special registers don't work. For example the testConnection() is not working.

 

It must be like this:

Wire.beginTransmission(devAddr);
Wire.write(regAddr);
Wire.endTransmission(false);
Wire.requestFrom(devAddr, (uint8_t)min(length - k, BUFFER_LENGTH));

Then the regAddr is sent but the connection is not closed. This way everything works fine.

 

It took me quite a while to figure this out. And it also made me create my own library, but I hate competing libraries :-)

So I would like to contribute this to the devlib, but I'm not experienced how to do this. Should I sent a pullrequest on github? And how could I make sure not to break the behavior with other i2c devices. I don't think it would break, but how can I be sure of this?

Since I will heavily use the mpr I will be happy to contribute some more mpr related stuff like functions and examples, I guess this could be done with pullrequests as well.

 

edit: The same problem seems to exist with the FastWire implementation.

 

Cheers

bechtold

Link to comment
Share on other sites

  • 7 years later...

Hi all! My name is Gaby. How are you doing? My team and I provide assistance with online r programming assignment help, programming in different languages, from Java to Python, c assignment helper and much more. And also we can help you with your homework in mathematics, physics, chemistry, history to make an essay for you on any topic or report. Are you still thinking? Then we will surprise you with good prices!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...