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.

Tiva™ C Series TM4C1294 Connected LaunchPad - I2C MasterBusy never completes

I am using I2C on the launchpad connected to a TelAire ChipCap2 that reads humidity and temperature. I cant get beyond the very first MasterBusy(). My code is:

    g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                             SYSCTL_OSC_MAIN |
                                             SYSCTL_USE_PLL |
                                             SYSCTL_CFG_VCO_480), 120000000);

    uint32_t baseAddress = I2C0_BASE;
    uint32_t sysCtlPeripheral = SYSCTL_PERIPH_I2C0;
    //
    // Disable, Reset and Enable the I2C Module Instance
    //
    ROM_SysCtlPeripheralDisable(sysCtlPeripheral);
    ROM_SysCtlPeripheralReset(sysCtlPeripheral);
    ROM_SysCtlPeripheralEnable(sysCtlPeripheral);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    GPIOPinConfigure(GPIO_PB2_I2C0SCL);
    GPIOPinConfigure(GPIO_PB3_I2C0SDA);
    GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);  // SDA
    GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2); // SCL

    //
    // Configure the I2C Baud Rate
    //
    I2CMasterInitExpClk(baseAddress,g_ui32SysClock,false); // true = 400Kbps, false = 100Kbps

    //
    // Enable I2C Master Operation
    //
    I2CMasterEnable(baseAddress);
    ROM_SysCtlDelay(10000);  // suggested from someones example between I2CMasterInitExpClk and I2CMasterSlaveAddrSet

    uint8_t testData[4];
    //uint32_t baseAddress = I2C0_BASE;
    uint32_t i2cAddress = 0x28;
    I2CMasterSlaveAddrSet(baseAddress, i2cAddress, I2C_READ);

     I2CMasterControl(baseAddress, I2C_MASTER_CMD_BURST_RECEIVE_START);  // does this actually puts something out on bus?
     while(I2CMasterBusy(baseAddress));  // after this would be the correct time to check for I2C_ACK ?  ##### Always Stuck Here #######
       testData[0] = I2CMasterDataGet(baseAddress);

     I2CMasterControl(baseAddress, I2C_MASTER_CMD_BURST_RECEIVE_CONT);  // does this actually puts something out on bus?
     while(I2CMasterBusy(baseAddress));
       testData[1] = I2CMasterDataGet(baseAddress);

       I2CMasterControl(baseAddress, I2C_MASTER_CMD_BURST_RECEIVE_CONT);  // does this actually puts something out on bus?
     while(I2CMasterBusy(baseAddress));
       testData[2] = I2CMasterDataGet(baseAddress);

       I2CMasterControl(baseAddress, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);  // does this actually puts something out on bus?
     while(I2CMasterBusy(baseAddress));
       testData[3] = I2CMasterDataGet(baseAddress);

I have tried variations in MasterControl of

I2C_MASTER_CMD_SINGLE_RECEIVE
I2C_MASTER_CMD_BURST_RECEIVE_START

I have connected this device to a different processor to make sure device works, I2C address is correct and my pinout is correct.

I have connected on the breadboard adaptor:

61 - shield

62 - ground

67 - I2C0SCL (PB2 on processor)

69 - I2C0SDA (PB3 on processor)

98 - (+3.3 volts)

I'm not sure if pins are properly configured in software on launchpad (ie no conflict with other operations) or that the read is not properly constructed. (Shouldnt I need to explicitly test for slave ACK or is completion of MasterBusy() sufficient?)

The device has no command writes, just a single read multiple times.


Sorry if this is too much info, but can't see why I never get past the first MasterBusy().

Thanks for any help,

-Phil B


  • ok, that formatting was terrible... resending the question....



    I am using I2C on the launchpad connected to a TelAire ChipCap2 that reads humidity and temperature. I cant get beyond the very first MasterBusy(). My code is:

    g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    SYSCTL_OSC_MAIN |
    SYSCTL_USE_PLL |
    SYSCTL_CFG_VCO_480), 120000000);

    uint32_t baseAddress = I2C0_BASE;
    uint32_t sysCtlPeripheral = SYSCTL_PERIPH_I2C0;
    //
    // Disable, Reset and Enable the I2C Module Instance
    //
    ROM_SysCtlPeripheralDisable(sysCtlPeripheral);
    ROM_SysCtlPeripheralReset(sysCtlPeripheral);
    ROM_SysCtlPeripheralEnable(sysCtlPeripheral);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    GPIOPinConfigure(GPIO_PB2_I2C0SCL);
    GPIOPinConfigure(GPIO_PB3_I2C0SDA);
    GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3); // SDA
    GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2); // SCL

    //
    // Configure the I2C Baud Rate
    //
    I2CMasterInitExpClk(baseAddress,g_ui32SysClock,false); // true = 400Kbps, false = 100Kbps

    //
    // Enable I2C Master Operation
    //
    I2CMasterEnable(baseAddress);
    ROM_SysCtlDelay(10000); // suggested from someones example between I2CMasterInitExpClk and I2CMasterSlaveAddrSet

    uint8_t testData[4];
    //uint32_t baseAddress = I2C0_BASE;
    uint32_t i2cAddress = 0x28;
    I2CMasterSlaveAddrSet(baseAddress, i2cAddress, I2C_READ);

    I2CMasterControl(baseAddress, I2C_MASTER_CMD_BURST_RECEIVE_START); // does this actually puts something out on bus?
    while(I2CMasterBusy(baseAddress)); // after this would be the correct time to check for I2C_ACK ? ##### Always Stuck Here #######
    testData[0] = I2CMasterDataGet(baseAddress);

    I2CMasterControl(baseAddress, I2C_MASTER_CMD_BURST_RECEIVE_CONT); // does this actually puts something out on bus?
    while(I2CMasterBusy(baseAddress));
    testData[1] = I2CMasterDataGet(baseAddress);

    I2CMasterControl(baseAddress, I2C_MASTER_CMD_BURST_RECEIVE_CONT); // does this actually puts something out on bus?
    while(I2CMasterBusy(baseAddress));
    testData[2] = I2CMasterDataGet(baseAddress);

    I2CMasterControl(baseAddress, I2C_MASTER_CMD_BURST_RECEIVE_FINISH); // does this actually puts something out on bus?
    while(I2CMasterBusy(baseAddress));
    testData[3] = I2CMasterDataGet(baseAddress);

    I have tried variations in MasterControl of

    I2C_MASTER_CMD_SINGLE_RECEIVE
    I2C_MASTER_CMD_BURST_RECEIVE_START

    I have connected this device to a different processor to make sure device works, I2C address is correct and my pinout is correct.

    I have connected on the breadboard adaptor:

    61 - shield

    62 - ground

    67 - I2C0SCL (PB2 on processor)

    69 - I2C0SDA (PB3 on processor)

    98 - (+3.3 volts)

    I'm not sure if pins are properly configured in software on launchpad (ie no conflict with other operations) or that the read is not properly constructed. (Shouldnt I need to explicitly test for slave ACK or is completion of MasterBusy() sufficient?)

    The device has no command writes, just a single read multiple times.


    Sorry if this is too much info, but can't see why I never get past the first MasterBusy().

    Thanks for any help,

    -Phil B
  • This is the slave I2C protocol. Again please excuse if this is too much info....

  • Sorry but that was the wrong picture.That was for a command mode that vendor 'discourages' using.  The actual read is as follows:

  • First of all, please check if you have the pull up resistors on the SDA and SCL pins. Since you use the burst mode, you need to call I2CMasterBurstLengthSet() to configure the FIFO length before starting the transfer.

    I2CMasterControl(baseAddress, I2C_MASTER_CMD_BURST_RECEIVE_START)2CMasterControl(baseAddress, I2C_MASTER_CMD_BURST_RECEIVE_START) generates the start condition and puts the slave address and R/W bit on the bus.

    I2CMasterControl(baseAddress, I2C_MASTER_CMD_BURST_RECEIVE_CONT) clocks the data from the slave.
    I2CMasterControl(baseAddress, I2C_MASTER_CMD_BURST_RECEIVE_FINISH) clocks the data from the slave and generate the stop condition when the transfer is complete.

    Thanks and regards,

    Zhaohong
  • Thanks for the response. On the launchpad I needed to add the pull-ups external to the board on SDA and SCL signals so took a few days. Anyway works great now!
    Thanks again!
    -Phil B