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.

TMS320F28062: I2C repeat mode

Part Number: TMS320F28062


Hello,

I'm using a TMS320F28062 and I can succesfully send 4 bytes through I2C.

How can I send more than 4 bytes (for eg. 8 bytes), whithout a stop signal between them ?

The code for 4 bytes is the following:

   if (!I2caRegs.I2CSTR.bit.BB)    /* when the line is free */
    {
        I2caRegs.I2CFFTX.bit.TXFFRST=0;
        I2caRegs.I2CFFTX.bit.TXFFRST=1;
        for (i=0;i<4;i++)
        {
            I2caRegs.I2CDXR=(unsigned int)SndData[i]; /*FIFO*/
        }
        I2caRegs.I2CMDR.bit.MST=1;  //set master mode
        I2caRegs.I2CMDR.bit.TRX=1;  //set transmit mode
        I2caRegs.I2CCNT=4;       //set 4 bytes
        I2caRegs.I2CMDR.bit.STP=1;  //set stop
        I2caRegs.I2CMDR.bit.STT=1;  //set start
    }

If I want to send 8 bytes do I need to work in repeat mode ?

If yes, how do I modify the above source?

Thanks

Andrej

  • Andrej,

    The easiest way is to set I2CCNT to 8. When the transmit FIFO is empty (I2CFFTX.TXFFST == 0), write four more bytes.

    You can also use repeat mode if you'd like, but it doesn't really gain you anything in this case.
  • Hi Adam,

    thanks for your help. Now it works:

    For sending / receiving the I2C data I'm periodically calling the "I2C refresh" procedure.

    So when I need to send the 8 bytes, I do the procedure above (with the change that I load I2CCNT to 8 ).

    Then, in the second pass, I don't check the if (!I2caRegs.I2CSTR.bit.BB)  any more - I suppose the line is always busy, because the I2CCNT is still waiting for another 4 bytes.

    So instead of that I load another 4 bytes as you suggested:

    if (I2CFFTX.TXFFST == 0)

    {

    for (i=4;i<8;i++)
            {
                I2caRegs.I2CDXR=(unsigned int)SndData[i]; /*FIFO*/
            }

    }

    Thanks and best regards

    Andrej