This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

i2c example with different registers

Hello,

I am new to this world and I tried to study the I2C protocol and follow the examples for the MSP430FRXXXX boards (the MSP430FR57xx_uscib0_i2c_10.c)

I have to get the data from the MPU9250, to be precise 14 bytes starting from the address 0x3B. 

The address of the device is 0x68.

I couldn't find an example where it is possible to set the address where to read from. I thought that the MSP should send the address of the device and then send the address of the register (at least from what i understood from protocol), but in the example of the TI the interrupt handles only the Receiving process, having set just the device address at the beginning.

Does someone know here to find an example code or a tutorial to handle it (I thought it would have been easy to find, I was wrong)?

thank you.

  • Hi Ivan,

    I don't really know the slave device you are interfacing with, but many devices like this use an I2C format like:
    start + device address + write bit set, tx register address/cmd for slave, repeated start + device address + read bit set, rx data from slave, stop. This is basically an additional protocol layer implemented on top of the bare I2C standard. The MSP430 code example you saw before is showing you just a basic I2C example, only what's required by the I2C standard. However many devices do implement an additional protocol structure like the one described above on top of I2C, it's not a requirement of I2C and tends to be somewhat custom/vary depending on whichever slave device you are trying to talk to. Think of it like I2C is your physical communication layer, and this extra read-register format is a higher layer on top of that which you are simply transporting over your physical layer.
     
    You can find an example of this type of additional communication format in some of the MSP430 examples that interface with other devices - one that I can think of that has an example with FR57xx as the master, is the code for the RF430CL330HTB. Here is the code: www.ti.com/.../sloc290

    You'll of course have to modify this to work with the commands/registers and format needed for this slave device that you are trying to control, but hopefully it gives you some ideas of how to start.

    Regards,
    Katie

  • Thank you for your help. I am working with an IMU: MPU9250.
    I tried to read the example you link, but also that one is completely different from the ones I've already checked. There is no use of the responses of I2C inside the I2C interrupt vector.
    Anyway I will try to study your guidelines to understand the other examples better.

    Regard,
    Ivan

**Attention** This is a public forum