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.

Regarding I2C interface to EEPROM using TMS320F28335



I am trying to implement I2C interface,after initialization of slave address on bus, data is coming to bus properly though i am putting to I2CDXR Register directly

Please check this routine,

Uint16 I2CA_WriteData(struct I2CMSG *msg)
{
Uint16 i;

// Wait until the STP bit is cleared from any previous master communication.
// Clearing of this bit by the module is delayed until after the SCD bit is
// set. If this bit is not checked prior to initiating a new message, the
// I2C could get confused.
if (I2caRegs.I2CMDR.bit.STP == 1)
{
return I2C_STP_NOT_READY_ERROR;
}

// Setup slave address
I2caRegs.I2CSAR = msg->SlaveAddress;

// Check if bus busy
if (I2caRegs.I2CSTR.bit.BB == 1)
{
return I2C_BUS_BUSY_ERROR;
}

// Setup number of bytes to send
// MsgBuffer + Address
I2caRegs.I2CCNT = msg->NumOfBytes+2;

// Setup data to send
I2caRegs.I2CDXR = msg->MemoryHighAddr;
I2caRegs.I2CDXR = msg->MemoryLowAddr;
// for (i=0; i<msg->NumOfBytes-2; i++)
for (i=0; i<msg->NumOfBytes; i++)

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

// Send start as master transmitter
// I2caRegs.I2CMDR.all = 0x6E20;
I2caRegs.I2CDXR= 0x2; 
I2caRegs.I2CDXR= 0xF;
I2caRegs.I2CMDR.all = 0x6E20;
return I2C_SUCCESS;
}

Is it like we can send data to buffer then putting data to I2CMDR after that?

Can anyone suggest me changes or any guideline to do this?

  • Vivek,


    There I2C module has a 16-byte FIFO that can hold some data. You need to enable it in order to use it. You can find information on this in the 2833x I2C reference guide, literature number SPRUG03:

  • Hello Adam, I am getting data in msgbuffer of CCS, But not on the pins of eZDSP board in form of waveform, what will be the reason behind this?
  • Are you initializing the I2C properly? Did you set up the GPIO mux to bring the I2C signals out to the pins? Do you have pull-ups on the I2C bus?

  • Thanks Adam,
    Please check the following routine for initialization for GPIO. Pull ups are present on the board.



    void InitI2CGpio()
    {

    EALLOW;
    /* Enable internal pull-up for the selected pins */
    // Pull-ups can be enabled or disabled disabled by the user.
    // This will enable the pullups for the specified pins.
    // Comment out other unwanted lines.

    GpioCtrlRegs.GPBPUD.bit.GPIO32 = 0; // Enable pull-up for GPIO32 (SDAA)
    GpioCtrlRegs.GPBPUD.bit.GPIO33 = 0; // Enable pull-up for GPIO33 (SCLA)

    /* Set qualification for selected pins to asynch only */
    // This will select asynch (no qualification) for the selected pins.
    // Comment out other unwanted lines.

    GpioCtrlRegs.GPBQSEL1.bit.GPIO32 = 3; // Asynch input GPIO32 (SDAA)
    GpioCtrlRegs.GPBQSEL1.bit.GPIO33 = 3; // Asynch input GPIO33 (SCLA)

    /* Configure SCI pins using GPIO regs*/
    // This specifies which of the possible GPIO pins will be I2C functional pins.
    // Comment out other unwanted lines.

    GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 0; // Configure GPIO32 for SDAA operation
    GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 1; // Configure GPIO33 for SCLA operation

    EDIS;
    }