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: F28035 communicates with TI BQ32002 through I2C interface. First execute I2C LoopBack communication problem

Part Number: TMS320F28035
Other Parts Discussed in Thread: BQ32002

The above is the connection circuit diagram of F28035 I2C interface and BQ32002.

Question 1: First test the self-receiving and spontaneous functions of I2C LoopBack. Slave address location signal is set to 0x003F. As shown above, use an oscilloscope to measure the signal. The location information indicates that the location information set by 0x007F is different from the program code. However, DATA data can be sent and received correctly. Can't understand why the location information is different and the data can be correct?

Question 2: The same Slave Address position signal 0x003F sends the data again. The SDA and SCL waveforms measured by the oscilloscope are shown in the figure below. The two waveforms show the same phenomenon, but the DATA data can be successfully received by itself. It feels like SDA and SCL are shorted together. The use of a multimeter meter measurement found that it is indeed shorted. The solution will not be shorted as long as the power of the board is turned off and restarted. SDA and SCL will be short-circuited after a piece of information, what is the reason?

Question 3: If you continuously use the same Slave Address location to send data, you will get the following waveform. The waveform of the location information cannot be interpreted, but the DATA data can also be successfully received by itself.

Attach the program code.

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.GPAPUD.bit.GPIO28 = 0;    // Enable pull-up for GPIO28 (SDAA)
//	GpioCtrlRegs.GPAPUD.bit.GPIO29 = 0;	   // Enable pull-up for GPIO29 (SCLA)

	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.GPAQSEL2.bit.GPIO28 = 3;  // Asynch input GPIO28 (SDAA)
//    GpioCtrlRegs.GPAQSEL2.bit.GPIO29 = 3;  // Asynch input GPIO29 (SCLA)

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

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

//	GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 2;   // Configure GPIO28 for SDAA operation
//	GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 2;   // Configure GPIO29 for SCLA operation

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

    EDIS;
}


void i2c_init(void){

/************I2C LOOPBACK INIT****************/
    EALLOW;

    SysCtrlRegs.PCLKCR0.bit.I2CAENCLK = 1;

    I2caRegs.I2COAR=0x003F;  //7-bit addressing

    I2caRegs.I2CMDR.bit.IRS = 0;
    I2caRegs.I2CMDR.bit.DLB=1;

    I2caRegs.I2CPSC.all = 5;   //  7M <= 60M/(PSC+1)  <=12M
    I2caRegs.I2CCLKL = 7;
    I2caRegs.I2CCLKH = 8;
    I2caRegs.I2CMDR.bit.IRS = 1;

    EDIS;
/************I2C LOOPBACK INIT***************END*/

}


void I2C_WriteData(unsigned char data)
{
    I2caRegs.I2CSAR = 0x003F;
    I2caRegs.I2CMDR.bit.MST = 1;
    I2caRegs.I2CMDR.bit.TRX = 1;
    I2caRegs.I2CMDR.bit.STT = 1;
    I2caRegs.I2CMDR.bit.STP = 1;

    while(I2caRegs.I2CSTR.bit.BB!=1);
    I2caRegs.I2CDXR = data;
}

unsigned char I2C_ReadData()
{
    unsigned char data;
    I2caRegs.I2CMDR.bit.TRX = 0;
    I2caRegs.I2CMDR.bit.STT = 1;
    I2caRegs.I2CMDR.bit.STP = 1;
    while(I2caRegs.I2CSTR.bit.RRDY!=1);
    data = I2caRegs.I2CDRR&0x00ff;
    return data;
}

void main(void) {//�D�{��


	Hardware();		//�w���l��
	firmware();		//�����l��
	DELAY_US(20000);


	while(1){

    switch(TestCounter){
        case 1:   {
            I2C_WriteData('A');
            testdata=I2C_ReadData();
            TestCounter=0;
            break;
             }
        case 2: {
            I2C_WriteData('5');
            testdata=I2C_ReadData();
            TestCounter=0;
            break;
            }
        }
	}

  • Hi,

    Your first waveform looks correct to me. Your 2nd and 3rd waveforms seem incorrect and like you're experiencing a short like you said. This looks to be a hardware issue, but you're saying it does not appear shorted after power cycling the board?

    You are using the digital loop-back mode in all of these tests you've shown?

    Since you have an external pull-up resistor you can disable the internal pull-ups for communicating with BQ32002:

    	GpioCtrlRegs.GPBPUD.bit.GPIO32 = 1;    // disable internal pull-up for GPIO32 (SDAA)
    	GpioCtrlRegs.GPBPUD.bit.GPIO33 = 1;	   // disable internal pull-up for GPIO33 (SCLA)

    Best,

    Kevin