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.

TMS320F2808: I2C code operation clarification

Part Number: TMS320F2808
Other Parts Discussed in Thread: C2000WARE

In the I2C EEPROM example for F2808 provided, I am confused regarding the timing of code vs. what is actually happening and I am just looking for clarification.

The code in question is the following:

// Setup data to send
I2caRegs.I2CDXR = msg->MemoryHighAddr;
I2caRegs.I2CDXR = msg->MemoryLowAddr;

for (i=0; i<msg->NumOfBytes; i++)
{
    I2caRegs.I2CDXR = *(msg->MsgBuffer+i);
}

/*
* Bit Field Value Description
* 14 FREE 1 action taken by the I2C module when a debugger breakpoint
* 13 STT 1 START condition bit
* 11 STP 1 STOP condition bit
* 10 MST 1 Master mode bit
* 9 TRX 1 Transmitter mode bit
* 5 IRS 1 I2C module reset bit
* 0110 1110 0010 0000
*/
// Send start as master transmitter
I2caRegs.I2CMDR.all = 0x6E20;

return I2C_SUCCESS;

Based on the documentation, when data is written to the I2CDXR register, it is then copied to the I2CXSR register and then bit shifted out on the SDA line. However, the Start, Stop and TRX bit are set after all the data has been bit shifted out the SDA line based on the 'for loop'. What mechanism stops/delays the bit shifting until the I2CMDR register is written to? Is there depth to the I2CDXR?

  • Hi Jeffrey,

    Is there depth to the I2CDXR?

    Yes, this is actually right when the I2C is used in FIFO mode. The I2CDXR actually acts as the 16-byte FIFO in this case. So in the example the I2C FIFO is filled with data first by writing to I2CDXR, then when the below line is executed the I2C comms will actually begin (START condition, Slave address, data, etc.).

    // Send start as master transmitter
    I2caRegs.I2CMDR.all = 0x6E20;

    I might recommend you take a look at the newer F2806x I2C examples in C2000ware, as they're easier to follow and you can utilize the functions. The I2C modules between these devices are virtually the same, just the FIFO sizes differ I think. Directory locations for the examples below:

    C:\ti\c2000\C2000Ware_3_04_00_00\device_support\f2806x\examples\c28\i2c_Lib_eeprom_polling

    C:\ti\c2000\C2000Ware_3_04_00_00\device_support\f2806x\examples\c28\i2c_Lib_eeprom_interrupt

    Best,

    Kevin