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 Slave On TM4C1294 Board



Hey guys,

I currently am trying to set up my TivaWare board as an I2C slave that is communicating with a 4D uLCD-24PTU board. When I try to run my code, the interrupt never seems to fire. Also, it looks like an ACK is being sent, but then the SDA line is then left high, causing the 4D board to get confused and stop transmitting. I think this looks like my Pins aren't being properly set up, but I'm not sure what else I need to do. My configure I2C and I2C interrupt functions are below:

void ConfigureI2C(void) //CHARLES
{
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    SysCtlPeripheralEnable(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);

    I2CSlaveInit(I2C0_BASE, 0x23); //address is x23?

    I2CIntRegister(I2C0_BASE, UpdateDisplay);

}

void UpdateDisplay(void) //CHARLES
{

      if(I2CSlaveStatus(I2C0_BASE) == I2C_SLAVE_ACT_TREQ)
     {
              I2CSlaveDataPut(I2C0_BASE, data?);
     } else if(I2CSlaveStatus(I2C0_Base) == I2C_SLAVE_ACT_RREQ)
     {
              I2CSlaveDataGet(I2C0_BASE);
     }
     I2CSlaveIntClear();
     I2CSlaveEnable();

}

I'm more concerned about just getting the interrupt to fire at this point, as it seems like my configuration is messing things up. Would you guys be able to help me figure out how to properly configure this so pins B2 and B3 are the SCL and SDA lines respectively?

Thanks a bunch!

Charles

  • If you don't have any other devices on the I2C bus than your 4D board and the TM4C1294, then an ACKd slave address would tell you that the pins are properly configured.

    As for the interrupt, you are missing calls to I2CSlaveIntEnable[Ex]. Also, what's the I2CSlaveEnable doing in the interrupt handler?

    The "SDA left high" is probably caused by the TM4C129 stretching the clock, waiting for you to write/read from the data register. That will most probably self-heal once you get the interrupt working.

  • Aha! I had to add both the I2CSlaveIntEnable AND the I2CSlaveIntEnableEx and now the interrupt is firing! I also removed the extraneous I2CSlaveEnable in the interrupt handler and everything seems to be working fine!

    Thank you!
    Charles