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.

CCS/TMS320F28034: question about TMS320F28034 model I2C control AT24C08 for read or write?

Part Number: TMS320F28034

Tool/software: Code Composer Studio

Dear  TI team:

 my question as fellow:

the pin of AT24C08 A0、A1、A2、WP  connect GND

#define EEPROM_SLAVE_ADDR      (0xA0 >> 1) (p0 p1=00 :default comunication with block zero)

void Init_I2c(void)

{
 GpioCtrlRegs.GPBPUD.bit.GPIO32 = 0;    // Enable pull-up for GPIO32 (SDAA)
 GpioCtrlRegs.GPBPUD.bit.GPIO33 = 0;    // Enable pull-up for GPIO33 (SCLA)
 GpioCtrlRegs.GPBQSEL1.bit.GPIO32 = 3;  // Asynch input GPIO32 (SDAA)
    GpioCtrlRegs.GPBQSEL1.bit.GPIO33 = 3;  // Asynch input GPIO33 (SCLA)
 GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 1;   // Configure GPIO32 for SDAA operation
 GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 1;   // Configure GPIO33 for SCLA operation

    // Initialize I2C
    I2caRegs.I2CMDR.all = 0;//I2C reset

    I2caRegs.I2CPSC.all = 5;      // Prescaler - need 7-12 Mhz on module clk 60Mhz/(5+1)=10mhz system clk is 60M,using Internal Oscillator 1
  
    //clk=100khz
    I2caRegs.I2CCLKL = 50;   // NOTE: must be non zero
    I2caRegs.I2CCLKH = 40;   // NOTE: must be non zero

   // I2caRegs.I2CIER.all = 0x24;  // Enable SCD & ARDY __interrupts
    I2caRegs.I2CIER.all = 0x00;  // no __interrupts

    I2caRegs.I2CMDR.bit.IRS = 1;//I2C enable   whether is or not  the pin of SCL can detect  square ware after set IRS?   if  not  when is SCL can detect square ware???
    I2caRegs.I2CMDR.bit.FREE = 1;//interrupt 
    I2caRegs.I2CFFTX.all = 0x6040; // Enable FIFO mode and TXFIFO
    I2caRegs.I2CFFRX.all = 0x2044; // Enable RXFIFO, clear RXFFINT,
  
}

curr_Msg.MsgStatus = I2C_MSGSTAT_SEND_WITHSTOP;
   curr_Msg.SlaveAddress = EEPROM_SLAVE_ADDR;
  // curr_Msg.MemoryHighAddr = paramData[1];
   curr_Msg.MemoryLowAddr = paramData[2];
   curr_Msg.NumOfBytes =1;
   curr_Msg.MsgBuffer[0] = paramData[4];
   I2CA_WriteData(&curr_Msg);//use fellow function?


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+1;
 //   I2caRegs.I2CDXR = msg->MemoryHighAddr;
   // Setup data to send
   I2caRegs.I2CDXR = msg->MemoryLowAddr;

   for (i=0; i<msg->NumOfBytes; i++)
   {
      I2caRegs.I2CDXR = *(msg->MsgBuffer+i);
   }
   I2caRegs.I2CFFTX.bit.TXFFINTCLR =1;
   /*
    * clear flag bit
    */
   // Send start as master transmitter
   I2caRegs.I2CMDR.all = 0x6E20;// software run this ,the pin of SCL and SDA  cannot detect  ware ,and why? and I2CFFTX.bit.TXFFST =I2CCNT ,why???

   while(I2caRegs.I2CFFTX.bit.TXFFST !=0){}//procedure stop this ????

//系列上调试过的没有什么问题,只是更改了一个EEPROM内部写入的地址,望指点
   if(I2caRegs.I2CSTR.bit.SCD == 1)
 I2caRegs.I2CSTR.bit.SCD = 1;
/*
 * SCD=1 清楚SCD 和NACK位
 */

   return I2C_SUCCESS;
}

procedure above have  tested  on TMS320F28377 control AT24C64,and resualt is OK .but on this condition donot work,

 

Thank you in advance!

Best regards!