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.

I2C0 Does Not Transmit Correct Data in Slave mode

I am developing witch the TM4C123HE6PZ, and use I2C0 to interface with the AST2500, and it works in slave mode. 

Data will incorrect when the master using repected start to do read action.

It works well when I manually issue command without repected start.

int I2C0IntHandler() {

unsigned char i2cData = 0;
unsigned long ulAct = 0;

I2CSlaveIntClear(I2C0_BASE);
ulAct = I2CSlaveStatus(I2C0_SLAVE_BASE);
switch (ulAct) {
case I2C_SLAVE_ACT_NONE:
break;
case I2C_SLAVE_ACT_RREQ_FBR:
case I2C_SLAVE_ACT_RREQ:
i2cData = I2CSlaveDataGet(I2C0_SLAVE_BASE);
ProcRecvData(i2cData);
break;
case I2C_SLAVE_ACT_TREQ:
if(getDataPos < getDateLen){
I2CSlaveDataPut(I2C0_SLAVE_BASE, getDataBuf[getDataPos]);
getDataPos++;
}
else{
I2CSlaveDataPut(I2C0_SLAVE_BASE, 0xE0);
}
break;
default:
break;
}

}

  • Hello Feng

    When a Repeated Start is issued does the master present a slave address first with the RW bit clear, and does the Slave ACK the bit?

    Regards
    Amit
  • Hi, Amit
    When a Repeated Start is issued. the master has presented a slave address first (slave address A1). and the Slave ACK the bit.
    Is it related to I2C_SLAVE_ACT_QCMD and I2C_SLAVE_ACT_QCMD_DATA?
    In the interrupt processing function I2C0IntHandler, I do not process I2C_SLAVE_ACT_QCMD and I2C_SLAVE_ACT_QCMD_DATA.
  • Hello Feng,

    No it is nothing to do with the QCMD mode. Did you plot a single transaction and see if that is being received correctly?

    Regards
    Amit
  • Hi Amit

    As the image showed, the single transaction is OK. The first line is the write command, the second line is the read command.

    But the master need to use repeated start to talk with TM4C, how can I implement it ?

    In additional, when the master using repeated start to do read action, sometimes data is correct, but sometimes data is incorrect. So, does the master need to delay sometimes before it will send the second start.

    Thanks

    Regards

    Feng 

  • Hello Feng,

    To be able to debug the issue, I would propose the following

    1. Configure 3 spare GPIO's as ouput
    2. Toggle GPIO-1 L->H->L when it enters the interrupt routine
    3. Toggle GPIO-2 L->H->L when it enters the condition I2C_SLAVE_ACT_RREQ is entered
    4. Toggle GPIO-2 L->H->L when it enters the condition I2C_SLAVE_ACT_TREQ is entered

    Now plot the GPIO toggles on a scope along with SCL and SDA and attach it to the forum post.

    Regards
    Amit