Jump to content
I2Cdevlib Forums

Recommended Posts

Hi,

I've searched hole forum and the Internet ant haven't found many (to be honest almost none) information if anyone have successfully implemented I2CDev library on BeagleBone Black. I would like to use it with MPU6050.

I've started to implement it, but without any success so far.

 

Below, there is one question abut this library, I hope it is not too big offtop.

 

What is the proper way of working this function:

int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout)

All the time I was thinking that it shoud read length bytes starting from regAddr. So for exaple

int8_t I2Cdev::readBytes(devAddr, 10, 4,  data, timeout)

would read bytes from registers 10, 11, 12 and 13.

 

But we have this function (from MPU6050 library):

void MPU6050::getFIFOBytes(uint8_t *data, uint8_t length) {
    I2Cdev::readBytes(devAddr, MPU6050_RA_FIFO_R_W, length, data);
}

and in my opinion it should read length bytes from one register (MPU6050_RA_FIFO_R_W = 74) byte by byte and this is something different from what I described before.

 

I have the same concers about writeBytes function.

 

I would appreciate any help with understanding this functions :)

Share this post


Link to post
Share on other sites

I managed to solve this. The problem was reading to many bytes as once. I was reading always the same amount of bytes (64 as this is the size of my buffer) but used only 42 (as this is the default size of DMP packet). As a result bytes were removed from FIFO without actually using them.

 

I will also answer the question I asked above: what is the proper way of working this function:

int8_t I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout)

It should read length bytes starting from register number regAddr at once.

I am not sure why it works fine while reading bytes from FIFO. We are reading 42 bytes at once starting from register number 116, so theoretically we will should read registers 116-157, but it seems to read byte by byte only from register 116. Anyway as I mentioned before, it seems to work fine.

Share this post


Link to post
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...
Sign in to follow this  

×
×
  • Create New...