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 Master on TM4C123GXL

I am trying to build an I2C Master interface using a minimalist approach that I based on the loopback example that came with the driver library.   I am trying to communicate with a Pololu MinIMU9v2 from a TM4C123GXL Launchpad, but every time I try to write to the bus, I am getting I2C_MASTER_ERR_ADDR_ACK and I2C_MASTER_ERR_DATA_ACK. Printing out the slave address shows that it looks right, so I'm thinking this may be something I may be doing wrong with the use of the TI Launchpad driver library.

Here's the initialization routine:

void
InitI2CBus(void)
{
    // Initialize the TM4C I2C hardware for I2C0
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_16MHZ);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    GPIOPinConfigure(GPIO_PB2_I2C0SCL);
    GPIOPinConfigure(GPIO_PB3_I2C0SDA);
    GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
    // Initialize the bus
    I2CMasterInitExpClk(I2C0_BASE, SysCtlClockGet(), false);
}

Here is the code that attempts to read a byte from the device:

uint8_t
ReadByte(uint8_t slaveAddr, uint8_t subAddr)
{
    // Write SUB
    I2CMasterSlaveAddrSet(I2C0_BASE, slaveAddr, false);

    I2CMasterDataPut(I2C0_BASE, subAddr);
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND);
    while(I2CMasterBusy(I2C0_BASE)) { }

    if (CheckError())
    {
        return 0;
    }

    // Read data
    I2CMasterSlaveAddrSet(I2C0_BASE, slaveAddr, true);
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
    while(I2CMasterBusy(I2C0_BASE)) { }
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
    while(I2CMasterBusy(I2C0_BASE)) { }

    uint8_t response = I2CMasterDataGet(I2C0_BASE);

    if (CheckError())
    {
        return 0;
    }

    return response;
}

Any ideas what I may be doing wrong?