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.

TMS320F28035 I2C Implementation

Other Parts Discussed in Thread: TMS320F28035

I have an implementation for I2C for the TMS320F28035. I had everything working for communication, had to make some setup changes with hardware and now the 28035 no longer communicates over the bus. I just want to verify that my code is correct.

I am seeing the SCL line go line once the command register is set but it never comes back high again for a new cycle.

static void InitI2CGpio()
{
   EALLOW;
   SysCtrlRegs.PCLKCR0.bit.I2CAENCLK = 1;
   // Enable pull-ups for I2C pins
   GpioCtrlRegs.GPBPUD.bit.GPIO32 = 1;
   GpioCtrlRegs.GPBPUD.bit.GPIO33 = 1;

   // Asynchronous input selection
   GpioCtrlRegs.GPBQSEL1.bit.GPIO32 = 3;
   GpioCtrlRegs.GPBQSEL1.bit.GPIO33 = 3;

   // Configure pin operation
   GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 1; // SDA
   GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 1; // SCL

   EDIS;
}

void I2CInit()
{
   InitI2CGpio();

   I2caRegs.I2CMDR.bit.IRS = 0; // Reset the I2C module

   I2caRegs.I2CPSC.all = 5; // Prescaler - need 7-12 Mhz on module clk
   I2caRegs.I2CCLKL = 5; // Allow more time when clock is low
   I2caRegs.I2CCLKH = 5; // Need less time when clock is high

   I2caRegs.I2CIER.all = 0; // Disable interrupts
   I2caRegs.I2CFFTX.all = 0; // Disable FIFO mode and TXFIFO

   I2caRegs.I2CMDR.bit.IRS = 1; // Take I2C out of reset
}

WORD I2CWrite(I2C_MESSAGE_T* message)
{
   WORD status = I2C_SUCCESS;

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

   // Setup number of bytes to send
   I2caRegs.I2CCNT = message->NumberOfBytes;

   for(WORD i = 0; i < message->NumberOfBytes; i++)
   {
      I2caRegs.I2CDXR = *(message->DataBuffer + i);
   }

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

   return status;

}

  • Hello Lucas,
    I have moved this to the appropriate E2E forum.
    -Francis Houde
  • I modified my post to remove the reference to the DAC as it was unnecessary information since my code is basic I2C. Can you please move my post back to the I2C forum? Thank you
  • Hello Lucas,
    I moved your question to the microcontroller E2E. They will be able to verify your code for that particular part. You may want to take some waveforms of the transactions and also have a schematic available. This will help verify your code and see if there are hardware conflicts.
    -Francis Houde
  • You are using I2C without the 4-level FIFO. If you want to do that, that's fine, but you can only send one byte at a time. You are also telling it to start after you've loaded I2CDXR. So it will only send one byte (the last one loaded to I2CDXR). You are loading several bytes into I2CDXR but it is only 1-level with FIFO disabled and once you tell it to start, it only has 1 byte (the last one in the message) in the buffer. Your I2C device is probably not acking back and causing the lines to stay held.

    Try using a different approach.

    -Send start command as master transmitter first (empty buffer is OK at this point).
    -Then, load I2CDXR and wait for it to finish transmitting the byte (using status flags) before loading the next byte.

    If you want to use the 4-level FIFO, you have to be careful. Load it with 4 bytes, wait for some bytes to be sent, then load the next, and so on.