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.

TM4C1294NCPDT: TM4C1294NCPDT I2C interface with TCA9555 not working

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: TCA9555

I am trying to interface an LED display board based on TCA9555 through i2c.   Used I2C0 in TM4c1294NCPDT.  Configured  Port0 as output in TCA9555.  However the LED is not on.  The code snippet below.

void iniitiic1(void)
{

//
// Enable the I2C0 peripheral
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
//
// Wait for the I2C0 module to be ready.
//
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_I2C0))
{
}

//
// Initialize Master and Slave
//
I2CMasterInitExpClk(I2C0_BASE, SysCtlClockGet(), true); //400 speed
//
// Specify slave address
//
I2CMasterSlaveAddrSet(I2C0_BASE, 0x27, false); //0x27 is the address and write only
//
// Place the character to be sent in the data register
//
I2CMasterDataPut(I2C0_BASE, 0x06); //configuration register command
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);

while(I2CMasterBusy(I2C0_BASE));
I2CMasterDataPut(I2C0_BASE, 0x00); //configuration register write bits
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);

while(I2CMasterBusy(I2C0_BASE));
I2CMasterSlaveAddrSet(I2C0_BASE, 0x27, false); //0x27 is the address and write only
I2CMasterDataPut(I2C0_BASE, 0x02);// data register command
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);

while(I2CMasterBusy(I2C0_BASE));
I2CMasterDataPut(I2C0_BASE, 0xAA); // data register data
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);

}

I just tried the TivaWare Peripheral Driver Library example with code added specific for TCA9555.

Help will be appreciated.

Regards,

Ramesh

  • Hi,

      You cannot use SysCtlClockGet() for below API. SysCtlClockGet() is only for TM4C123 MCU, not TM4C129. You must pass the return value of SysCtlClockFreqSet() for TM4C129 MCU. 

    I2CMasterInitExpClk(I2C0_BASE, SysCtlClockGet(), true); //400 speed

  • Thanks.  I have updated the code.  But still LED is not displaying.  Updated code below

    void iniitiic1(uint32_t systclk)
    {
    iicerr =0x0;
    //
    // Enable the I2C0 peripheral
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
    //
    // Wait for the I2C0 module to be ready.
    //
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_I2C0))
    {
    }

    GPIOPinConfigure(GPIO_PB2_I2C0SCL);
    GPIOPinConfigure(GPIO_PB3_I2C0SDA);
    GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
    GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
    I2CMasterEnable(I2C0_BASE);
    iicerr=1;
    //
    // Initialize Master and Slave
    //
    I2CMasterInitExpClk(I2C0_BASE, systclk, true); //400 speed
    //
    // Specify slave address
    //
    while(I2CMasterBusy(I2C0_BASE));
    I2CMasterSlaveAddrSet(I2C0_BASE, 0x27, false); //0x27 is the address and write only
    //
    // Place the character to be sent in the data register
    //
    I2CMasterDataPut(I2C0_BASE, 0x06); //configuration register command
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);

    while(I2CMasterBusy(I2C0_BASE));
    I2CMasterDataPut(I2C0_BASE, 0x00); //configuration register write bits
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);

    while(I2CMasterBusy(I2C0_BASE));
    I2CMasterSlaveAddrSet(I2C0_BASE, 0x27, false); //0x27 is the address and write only
    I2CMasterDataPut(I2C0_BASE, 0x02);// data register command
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);

    while(I2CMasterBusy(I2C0_BASE));
    I2CMasterDataPut(I2C0_BASE, 0xFF); // data register data
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);


    iicerr= I2CMasterErr(I2C0_BASE);

    }

  • HI, 

      I'm not familiar with TCA9555. Reading the TCA9555 datasheet, it shows that you put out the slave address, register address and then the data to write to a register. 

    Can you use logic analyzer to capture I2C bus? How does it compare with the above sequence of transaction?

    Also things to check:

     - Did you have a pullup resistor on the SCL and SDA buses?

     - Is TCA9555 operating at 400kbps? Your I2C is configured for 400k. I will suggest you start with standard mode at 100kbps first. Make sure everything works before you change to 400k. 

      - Is TCA9555 configured for 0x27 as the slave address?