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.

CCS/TM4C129ENCPDT: Problem acquiring MPU6050 data using the tm4c129e

Part Number: TM4C129ENCPDT

Tool/software: Code Composer Studio

Hi, I have been working with the MPU6050, following the Arduino configuration I was able to set the 0x6B register, also  it  looks that the MPU6050 is sending me the ACKs, but I have a problem acquiring the data from the x-axis accelometer, whose registers are 0x3B and 0x3C. The output (pui32DataRx) is always 0, I do not know where is the error. Here is the code, someone has configure the TM4c129 to work with the MPU6050 using I2C???

#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_i2c.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/i2c.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"

//*****************************************************************************
//
// Number of I2C data packets to send.
//
//*****************************************************************************
#define NUM_I2C_DATA 3
#define SLAVE_ADDRESS 0x68

uint32_t ui32SysClock;
uint32_t pui32DataTx[NUM_I2C_DATA];
uint32_t pui32DataRx[2];
uint32_t ejeX;
int end = 0;

//*****************************************************************************
//
// Configure the I2C0 master and slave and connect them using loopback mode.
//
//*****************************************************************************
int
main(void)
{

    uint32_t ui32Index;

    ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                           SYSCTL_OSC_MAIN |
                                           SYSCTL_USE_PLL |
                                           SYSCTL_CFG_VCO_480), 120000000);

    // The I2C0 peripheral must be enabled before use.

    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    GPIOPinConfigure(GPIO_PB2_I2C0SCL);
    GPIOPinConfigure(GPIO_PB3_I2C0SDA);

    GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
    GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);

//  I2CLoopbackEnable(I2C0_BASE);
    I2CMasterInitExpClk(I2C0_BASE, ui32SysClock, false);
    I2CSlaveEnable(I2C0_BASE);      // Lo puedo quitar
    I2CSlaveInit(I2C0_BASE, SLAVE_ADDRESS);     //Setea la dirección del esclavo
    I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, false);     // false para escribir al esclavo, true para leer al esclavo

    // Initalize the data to send.
    pui32DataTx[0] = 0x6B;
    pui32DataTx[1] = 0x00;

    for(ui32Index = 0; ui32Index < 2; ui32Index++)
    {

        I2CMasterDataPut(I2C0_BASE, pui32DataTx[ui32Index]);      // Place the data to be sent in the data register
        I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND);

        while(!(I2CSlaveStatus(I2C0_BASE) & I2C_SLAVE_ACT_RREQ)) // Espera ACK del esclavo del reconosimiento de datos
        {
        }

        pui32DataRx[ui32Index] = I2CSlaveDataGet(I2C0_BASE); // Lee la data del esclavo

        while(I2CMasterBusy(I2C0_BASE)) //Espera a que el modulo maestro termine con la transferencia
        {
        }

        end++;
    }

    I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, true);     // false para escribir al esclavo, true para leer al esclavo

    while (1)
    {
        I2CMasterDataPut(I2C0_BASE, 0x3B);      // Place the data to be sent in the data register
        I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);

        while(!(I2CSlaveStatus(I2C0_BASE) & I2C_SLAVE_ACT_TREQ)) // Espera ACK del esclavo del reconosimiento de datos
        {
        }

        pui32DataRx[0] = I2CMasterDataGet(I2C0_BASE)<<8;

        I2CMasterDataPut(I2C0_BASE, 0x3C);      // Place the data to be sent in the data register
        I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);

        while(!(I2CSlaveStatus(I2C0_BASE) & I2C_SLAVE_ACT_TREQ)) // Espera ACK del esclavo del reconosimiento de datos
        {
        }

        pui32DataRx[1] = I2CMasterDataGet(I2C0_BASE);
        ejeX = pui32DataRx[0]|pui32DataRx[1];
    }

//    return(0);
}

  • Sergio Mamani said:
    The output ... from the x-axis accelometer (pui32DataRx) ... is always 0

    You do not state, "the condition of the device" when such measurement is made.     Is it possible that by aligning that axis - with gravity's pull - your reading will, "shift from zero?"

    I've not looked at your code - such, "Quick/Dirty" test (my kind of test) appears an "eased & advantaged method" does it not?

    Very often - "helpers here inquire as to the presence of (effective) pull-up resistors" upon each of the 2 I2C signal lines.    Yet - you claim (some) register & ACK success - thus (some) resistor (must) be present...

    [edit] Several hours have now passed (since writing the above) and (my workday now over) I note:

    "while(I2CMasterBusy(I2C0_BASE))"    Has not this code been replaced - when employing the "129 family?"   I recall a "back to back" read of MCU status - which (proves able)to detect the change of state of the "129's" busy.    I don't use the 129 family - do check this - just in case.    In addition - year or more back - gifted vendor agent Amit Ashara produced a most valuable - I2C based APP Note - which resides (somewhere!)    (to my mind - vendor delights in making the discovery and/or location of such critical documents - difficult!)    I've endlessly protested - vendor responded by "banning LIKE."

  • Ok, using a logic analizer I was able to replicate in the TM4C , the configuration sequence that the Arduino use to configure the MPU6050 (just setting to 0x00 the PWR_MGMT_1 register), the MPU6050 sent the ACKs and everything is OK with that, from here I thought that the rest would be easy, because I know  how to use the burst sending using I2C, but the problem  comes for reading data.

    So again using the logic analyzer I was able to see what is the sequence of data that pass through the I2C bus, here is an image (using arduino):

    In first place the master have to write in the I2C bus the register from the xAxis (0x3B), then configurate the master for reading (re-start), and then just read the 16 bytes of data from the xAxis register. I have made the next code in order to write (0x3B) in the I2C bus, then configurate the master for reading, but for some reason, in the second while loop the code gets stuck in the marked line:

        while (1)
        {
            I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, false);           //False to write to the MPU6050
    
            I2CMasterDataPut( I2C0_BASE, 0x3B );                             //Send the register 0x3B
            I2CMasterControl( I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND );
            while(I2CMasterBusy(I2C0_BASE)) {}                               //HERE THE CODE GETS STUCK IN THE SECOND WHILE LOOP   <------------
            while(!(I2CSlaveStatus(I2C0_BASE) & I2C_SLAVE_ACT_RREQ)) {}
            pui32DataRx[0]=I2CSlaveDataGet(I2C0_BASE);
    
            I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, true);           //True to read from the MPU6050
    
            I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START); //Initiate the "burst read" and read the 0x3B register
            while(!(I2CSlaveStatus(I2C0_BASE) & I2C_SLAVE_ACT_TREQ)){};
            data[0]=I2CMasterDataGet(I2C0_BASE);
    
            I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);  //Read the next register 0x3C
            while(!(I2CSlaveStatus(I2C0_BASE) & I2C_SLAVE_ACT_TREQ)){};
            data[1]=I2CMasterDataGet(I2C0_BASE);
    
            I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH); //Finish the "burst read"
            while(!(I2CSlaveStatus(I2C0_BASE) & I2C_SLAVE_ACT_TREQ)){};
        }

    Here is the complete code:

    #include <stdbool.h>
    #include <stdint.h>
    #include "inc/hw_i2c.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/gpio.h"
    #include "driverlib/i2c.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"
    
    #define NUM_I2C_DATA 3
    #define SLAVE_ADDRESS 0x68
    
    uint32_t ui32SysClock;
    uint32_t pui32DataTx[NUM_I2C_DATA];
    uint32_t pui32DataRx[3];
    uint32_t data[4];
    uint32_t ejeX;
    int end = 0;
    
    int main(void)
    
    {
    
        ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                               SYSCTL_OSC_MAIN |
                                               SYSCTL_USE_PLL |
                                               SYSCTL_CFG_VCO_480), 120000000);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    
        GPIOPinConfigure(GPIO_PB2_I2C0SCL);
        GPIOPinConfigure(GPIO_PB3_I2C0SDA);
    
        GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
        GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
    
        I2CMasterInitExpClk(I2C0_BASE, ui32SysClock, false);
    //  I2CSlaveEnable(I2C0_BASE);
        I2CSlaveInit(I2C0_BASE, SLAVE_ADDRESS);                          //Set slave address
        I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, false);          //False to write
    
        pui32DataTx[0] = 0x6B;                                           //MPU6050  PWR_MGMT_1 Register
        pui32DataTx[1] = 0x00;                                           //Set to 0x00 the register PWR_MGMT_1
    
        I2CMasterDataPut( I2C0_BASE, pui32DataTx[0] );                   //Initiate the Burst sending first 0x6B
        I2CMasterControl( I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START );
        while(I2CMasterBusy(I2C0_BASE)) {}
        while(!(I2CSlaveStatus(I2C0_BASE) & I2C_SLAVE_ACT_RREQ)) {}
        pui32DataRx[0]=I2CSlaveDataGet(I2C0_BASE);
    
        I2CMasterDataPut( I2C0_BASE, pui32DataTx[1] );                  //Then the send the new value of the PWR_MGMT_1 register
        I2CMasterControl( I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_CONT );
        while(I2CMasterBusy(I2C0_BASE)) {}
        while(!(I2CSlaveStatus(I2C0_BASE) & I2C_SLAVE_ACT_RREQ)) {}
        pui32DataRx[1]=I2CSlaveDataGet(I2C0_BASE);
    
        I2CMasterControl( I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH );//Finish the Burst sending
        while(I2CMasterBusy(I2C0_BASE)) {}
        pui32DataRx[2]=I2CSlaveDataGet(I2C0_BASE);
    
        while (1)
        {
            I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, false);           //False to write to the MPU6050
    
            I2CMasterDataPut( I2C0_BASE, 0x3B );                             //Send the register 0x3B
            I2CMasterControl( I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND );
            while(I2CMasterBusy(I2C0_BASE)) {}                               //Here the code gets stuck in the second pass   <------------
            while(!(I2CSlaveStatus(I2C0_BASE) & I2C_SLAVE_ACT_RREQ)) {}
            pui32DataRx[0]=I2CSlaveDataGet(I2C0_BASE);
    
            I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, true);           //True to read from the MPU6050
    
            I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START); //Initiate the "burst read" and read the 0x3B register
            while(!(I2CSlaveStatus(I2C0_BASE) & I2C_SLAVE_ACT_TREQ)){};
            data[0]=I2CMasterDataGet(I2C0_BASE);
    
            I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);  //Read the next register 0x3C
            while(!(I2CSlaveStatus(I2C0_BASE) & I2C_SLAVE_ACT_TREQ)){};
            data[1]=I2CMasterDataGet(I2C0_BASE);
    
            I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH); //Finish the "burst read"
            while(!(I2CSlaveStatus(I2C0_BASE) & I2C_SLAVE_ACT_TREQ)){};
        }
    
    }

    Thanks in advance

  • Here is the code to get the data from the x Axis of the MPU6050, I share it because I do not see any complete solution on this forum for a problem that looks to be popular, maybe it is an easy problem to solve for some people (for me was hard because is my first I2C program) but it was really frustrating for me to found almost nothing about this topic on this forum, here is also a link to a I2C proyect that helps me a lot.

    https://github.com/lamarts/Tiva-TM4C-ARM-Coretex-M4---I2C-Sensor/blob/master/MCP9808_main.c

    Code:

    #include <stdint.h>
    #include <stdbool.h>
    #include <stdio.h>
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "inc/hw_gpio.h"
    #include "inc/hw_i2c.h"
    #include "driverlib/debug.h"
    #include "driverlib/fpu.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "driverlib/i2c.h"
    #include "utils/uartstdio.h"
    
    #define SLAVE_ADDRESS           0x68
    #define AMBIENT_TEMPERATURE     0x3B
    #define DEVICE_ID_REGISTER          0x3B
    #define MANUFACTURE_ID_REGISTER     0x07
    
    uint32_t ui32SysClock;
    uint32_t ui32SysClock_2;
    int a = 0;
    uint32_t pui32DataTx[3];
    uint32_t pui32DataRx[3];
    uint16_t X;
    
    void I2C_Init()
    {
        SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
        SysCtlPeripheralReset(SYSCTL_PERIPH_I2C0);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    
        GPIOPinConfigure(GPIO_PB2_I2C0SCL);
        GPIOPinConfigure(GPIO_PB3_I2C0SDA);
    
        GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
        GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
    
        I2CMasterInitExpClk(I2C0_BASE,4800000, false);
    }
    
    void xAxis_R(uint8_t ambient_temp_reg)
    {
      I2CMasterDataPut(I2C0_BASE, ambient_temp_reg);
      I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND);
    }
    
    
    uint16_t xAxis()
    {
      uint16_t UpperByte = 0;
      uint16_t LowerByte = 0;
      uint16_t UPM = 0;
      uint16_t xAxis = 0;
    
    
      I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, true);
    
      // Get first byte from slave and ack for more
      I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START);
      while(I2CMasterBusy(I2C0_BASE));
      UpperByte = I2CMasterDataGet(I2C0_BASE);
    
      I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
      while(I2CMasterBusy(I2C0_BASE));
      LowerByte = I2CMasterDataGet(I2C0_BASE);
    
      UPM = UpperByte<<8;
      xAxis = UPM | LowerByte;
      SysCtlDelay(600);
      return xAxis;
    
    }
    
    int main(void)
    {
        ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                               SYSCTL_OSC_MAIN |
                                               SYSCTL_USE_PLL |
                                               SYSCTL_CFG_VCO_480), 120000000);
    
    
        ui32SysClock_2 = SysCtlClockGet();
    
        I2C_Init();
    
        SysCtlDelay(500);
    
        pui32DataTx[0] = 0x6B;                                           //MPU6050  PWR_MGMT_1 Register
        pui32DataTx[1] = 0x00;                                           //Set to 0x00 the register PWR_MGMT_1
        I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, false);
        I2CMasterDataPut(I2C0_BASE, pui32DataTx[0] );
        I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);
        while(I2CMasterBusy(I2C0_BASE)){}
    
        I2CMasterDataPut(I2C0_BASE, pui32DataTx[1] );
        I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
        while(I2CMasterBusy(I2C0_BASE)){}
    
        I2CMasterControl( I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH );//Finish the Burst sending
        while(I2CMasterBusy(I2C0_BASE)) {}
        pui32DataRx[2]=I2CSlaveDataGet(I2C0_BASE);
    
        SysCtlDelay(500);
    
        while(1)
        {
            I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, false);
            xAxis_R(0x3B);
            while(I2CMasterBusy(I2C0_BASE)){}
    
            X = xAxis();
    
         }
    }
    

    This is not a complete solution, Y and Z axis, also gyroscope and temperature sensor are not in this code, once I complete it I will share through this post.

  • In your initial post you noted that your "X-Axis" data was (always) zero. It was suggested that you "align" that axis w/gravitational field - which should provide an, "escape from zero."

    Today you present an "X-Axis solution" - yet never comment upon the X-Axis data - now obtained. That's not (entirely) consistent - is it?

    Have you a better means to "generate accelerations" - so that ALL axis performance - may one day - be achieved?
  • Here is the code to get the raw data of the 3 axis accelerometer that is on the mpu6050 using the tm4c129,the data is the same that is obtained by using the arduino, that use the wire.h library.

    #include <stdint.h>
    #include <stdbool.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "inc/hw_gpio.h"
    #include "inc/hw_i2c.h"
    #include "driverlib/debug.h"
    #include "driverlib/fpu.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "driverlib/i2c.h"
    #include "utils/uartstdio.h"
    
    #define SLAVE_ADDRESS           0x68
    #define AMBIENT_TEMPERATURE     0x3B
    #define DEVICE_ID_REGISTER          0x3B
    #define MANUFACTURE_ID_REGISTER     0x07
    
    uint32_t ui32SysClock;
    uint32_t ui32SysClock_2;
    int a = 0;
    uint32_t pui32DataTx[3];
    uint32_t pui32DataRx[3];
    
    short * X;
    short XYZ[3];
    
    short UpperByte_X = 0;
    short LowerByte_X = 0;
    short UpperByte_Y = 0;
    short LowerByte_Y = 0;
    short UpperByte_Z = 0;
    short LowerByte_Z = 0;
    
    void I2C_Init()
    {
        SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
        SysCtlPeripheralReset(SYSCTL_PERIPH_I2C0);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    
        GPIOPinConfigure(GPIO_PB2_I2C0SCL);
        GPIOPinConfigure(GPIO_PB3_I2C0SDA);
    
        GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
        GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
    
        I2CMasterInitExpClk(I2C0_BASE,4800000, false);
    }
    
    void xAxis_R(uint8_t ambient_temp_reg)
    {
      I2CMasterDataPut(I2C0_BASE, ambient_temp_reg);
      I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);
    }
    
    short * xAxis()
    {
      static short EJES[3];
    
      I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, true);
    
      I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START);
      while(I2CMasterBusy(I2C0_BASE));
      UpperByte_X = I2CMasterDataGet(I2C0_BASE);
    
      I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
      while(I2CMasterBusy(I2C0_BASE));
      LowerByte_X = I2CMasterDataGet(I2C0_BASE);
    
      I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
      while(I2CMasterBusy(I2C0_BASE));
      UpperByte_Y = I2CMasterDataGet(I2C0_BASE);
    
      I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
      while(I2CMasterBusy(I2C0_BASE));
      LowerByte_Y = I2CMasterDataGet(I2C0_BASE);
    
      I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
      while(I2CMasterBusy(I2C0_BASE));
      UpperByte_Z = I2CMasterDataGet(I2C0_BASE);
    
      I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
      while(I2CMasterBusy(I2C0_BASE));
      LowerByte_Z = I2CMasterDataGet(I2C0_BASE);
    
      EJES[0] = UpperByte_X<<8 | LowerByte_X;
      EJES[1] = UpperByte_Y<<8 | LowerByte_Y;
      EJES[2] = UpperByte_Z<<8 | LowerByte_Z;
    
      SysCtlDelay(250);
      return EJES;
    
    }
    
    int main(void)
    {
        ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                               SYSCTL_OSC_MAIN |
                                               SYSCTL_USE_PLL |
                                               SYSCTL_CFG_VCO_480), 120000000);
    
    
        ui32SysClock_2 = SysCtlClockGet();
    
        I2C_Init();
    
        SysCtlDelay(500);
    
        pui32DataTx[0] = 0x6B;                                           //MPU6050  PWR_MGMT_1 Register
        pui32DataTx[1] = 0x00;                                           //Set to 0x00 the register PWR_MGMT_1
        I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, false);
        I2CMasterDataPut(I2C0_BASE, pui32DataTx[0] );
        I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);
        while(I2CMasterBusy(I2C0_BASE)){}
        pui32DataRx[0]=I2CSlaveDataGet(I2C0_BASE);
    
        I2CMasterDataPut(I2C0_BASE, pui32DataTx[1] );
        I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
        while(I2CMasterBusy(I2C0_BASE)){}
        pui32DataRx[1]=I2CSlaveDataGet(I2C0_BASE);
    
        I2CMasterControl( I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH );//Finish the Burst sending
        while(I2CMasterBusy(I2C0_BASE)) {}
        pui32DataRx[2]=I2CSlaveDataGet(I2C0_BASE);
    
        SysCtlDelay(500);
    
        while(1)
        {
            I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, false);
            xAxis_R(0x3B);
            while(I2CMasterBusy(I2C0_BASE)){}
            X = xAxis();
            XYZ[0] = X[0];
            XYZ[1] = X[1];
            XYZ[2] = X[2];
         }
    }
    

    Hope this can help anyone who needs it

  • Hi,

    Did you noticed there are two files: mpu6050.c, mpu6050.h in Tiva/sensorlib folder, with API functions ready to be used - seems to me some extra work to be done if you follow arduino - you just don't know what version is, and even knowing that, there are differences between internal hardware of micros...

  • I do not have the link with me know, but there were problems with the mpu6050 library related to the version of the compiler, I have tried them, and I got the compiler error.