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/TMS320F28377D: 28377D i2c

Part Number: TMS320F28377D
Other Parts Discussed in Thread: CONTROLSUITE, C2000WARE

Tool/software: Code Composer Studio

Hello Guys.

I need help I2C communication of MPU6500 sensors.

I search a lot of information on online, but I don't finish yet.

I don't know why the sensors doesn't working.

Attached my Main.c Code.

void main(void)
{

InitSysCtrl();

InitGpio();

EALLOW;

GpioCtrlRegs.GPCPUD.bit.GPIO91 = 0;
GpioCtrlRegs.GPCPUD.bit.GPIO92 = 0;

GpioCtrlRegs.GPCQSEL2.bit.GPIO91 = 3;
GpioCtrlRegs.GPCQSEL2.bit.GPIO92 = 3;

GpioCtrlRegs.GPCGMUX2.bit.GPIO91 = 1;
GpioCtrlRegs.GPCMUX2.bit.GPIO91 = 2;


GpioCtrlRegs.GPCGMUX2.bit.GPIO92 = 1;
GpioCtrlRegs.GPCMUX2.bit.GPIO92 = 2;

EDIS;

DINT;

InitPieCtrl();

IER = 0x0000;
IFR = 0x0000;

InitPieVectTable();

EALLOW;

PieVectTable.I2CA_INT = &i2c_int1a_isr;

EDIS;

I2CA_Init();

PieCtrlRegs.PIEIER8.bit.INTx1 = 1;

IER |= M_INT8;
EINT;

I2CA_WriteData(0x68, 0x6B, 0x00);
DELAY_US(100);
Check_flag++;

I2CA_WriteData(0x68, 0x6C, 0x00);
DELAY_US(100);
Check_flag++;

for(;;)
{
I2CA_ReadData(0x68, 0x75, 1, 1);
Transmitted_flag++;
DELAY_US(500000);
}

void I2CA_Init(void)

{
I2caRegs.I2CMDR.bit.IRS = 0;
I2caRegs.I2CPSC.all = 19; // Prescaler - need 7-12 Mhz on module clk
I2caRegs.I2CCLKL = 60; // NOTE: must be non zero
I2caRegs.I2CCLKH = 30; // NOTE: must be non zero
I2caRegs.I2CIER.all = 0x24; // Enable SCD & ARDY __interrupts

I2caRegs.I2CMDR.all = 0x0020; // Take I2C out of reset
// Stop I2C when suspended

I2caRegs.I2CFFTX.all = 0x6000; // Enable FIFO mode and TXFIFO
I2caRegs.I2CFFRX.all = 0x2040; // Enable RXFIFO, clear RXFFINT,
I2caRegs.I2CMDR.bit.IRS = 1;
}

void I2CA_WriteData(Uint16 Dev_Addr, Uint16 Reg_Addr, Uint16 Data)
{

while(I2caRegs.I2CMDR.bit.STP == 1);
while(I2caRegs.I2CSTR.bit.BB == 1);

I2caRegs.I2CSAR.all = Dev_Addr;
I2caRegs.I2CCNT = 2;
I2caRegs.I2CDXR = Reg_Addr;
I2caRegs.I2CDXR = Data;

I2caRegs.I2CMDR.all = 0x2E20;
}


void I2CA_ReadData(Uint16 Dev_Addr, Uint16 Reg_Addr, Uint16 len, Uint16 Return_len)
{

while(I2caRegs.I2CMDR.bit.STP == 1)
while(I2caRegs.I2CSTR.bit.BB == 1)

I2caRegs.I2CSAR.all = Dev_Addr;
I2caRegs.I2CCNT = len;
I2caRegs.I2CDXR = Reg_Addr;
I2caRegs.I2CMDR.all = 0x2620; // Send data to setup EEPROM address

DELAY_US(2);

I2caRegs.I2CCNT = Return_len;
I2caRegs.I2CMDR.all = 0x2C20; // Send data to setup EEPROM address
}


__interrupt void i2c_int1a_isr(void)
{

IntSource = I2caRegs.I2CISRC.all;
I2C_NUMBYTES = I2caRegs.I2CFFRX.bit.RXFFST;

if(IntSource == I2C_SCD_ISRC)
{

Rx_Buff = I2caRegs.I2CDRR.all;

Received_flag++;
}

else if(IntSource == I2C_ARDY_ISRC)
{
if(I2caRegs.I2CSTR.bit.NACK == 1)
{
I2caRegs.I2CMDR.bit.STP = 1;
I2caRegs.I2CSTR.all = I2C_CLR_NACK_BIT;
}
}

PieCtrlRegs.PIEACK.all = PIEACK_GROUP8;
}

}

  • Hello there!

    We are happy to clarify the behavior of any bit/register/features of the module. All peripherals have examples in ControlSuite/C2000Ware. You may want to compare your code with the examples to see where the problem might lie. Please continue to debug your code and use the forum to ask specific questions.

    How is the sensor "not working"? Are you not receiving any data? Can you verify that you are transmitting any data with an oscilloscope? If you give a bit more information on what you are doing and what debug you have done thus far, we will be better equipped to help you out.