Part Number: TMS320F28379D
Tool/software: Code Composer Studio
Hi. I'm using TMS320f28379d Launchpad and I want to read the MPU9250 9-DOF sensor with I2C Protokol. I have tried too many things to accomplish that but It is still not working. I have read almost 10 times the datasheet but still, I couldn't find the exact problem and I'm a newbie on this MCU. I will share a code and Logic analyzer results. Can you help me with that?
Logic Analyzer Results
The code:
I2caRegs.I2CMDR.bit.IRS = 1; // I2C enable
// Make sure I2C is not busy and has stopped
while (I2caRegs.I2CSTR.bit.BB == 1); // busy loop
I2caRegs.I2CSTR.bit.SCD = 1; // Clear the SCD bit (stop condition bit)
while(I2caRegs.I2CMDR.bit.STP == 1); // stop bit loop
I2caRegs.I2CSAR.bit.SAR = Slave_Adress; // I2C slave address
while (I2caRegs.I2CSTR.bit.BB == 1); // still busy?
//I2caRegs.I2CMDR.all = 0x2620; // start, no stop bit, master, tx, reset I2C 00100110
I2caRegs.I2CMDR.bit.NACKMOD = 0; // NACK mode bit
I2caRegs.I2CMDR.bit.FREE = 0; // Stop I2C when suspended
I2caRegs.I2CMDR.bit.STT = 1; // START condition bit
I2caRegs.I2CMDR.bit.STP = 1; // STOP condition bit
I2caRegs.I2CMDR.bit.MST = 1; // Master mode
I2caRegs.I2CMDR.bit.TRX = 1; // Transmitter mode
I2caRegs.I2CMDR.bit.XA = 0; // 7-bit addressing mode
I2caRegs.I2CMDR.bit.RM = 0; // Nonrepeat mode
I2caRegs.I2CMDR.bit.DLB = 0; // Digital loopback mode is disabled
I2caRegs.I2CMDR.bit.IRS = 1; // The I2C module is enabled
I2caRegs.I2CMDR.bit.STB = 0; // The I2C module is not in the START byte mode
I2caRegs.I2CMDR.bit.FDF = 0; // Free data format mode is disabled
I2caRegs.I2CMDR.bit.BC = 0; // 8 bits per data byte
I2caRegs.I2CCNT = 1; // assume register address is one byte
while(I2caRegs.I2CSTR.bit.XRDY == 0); // Do nothing till bus is free
I2caRegs.I2CDXR.bit.DATA = Who_I_Am; // register address of the sensor (1 byte)
while(!I2caRegs.I2CSTR.bit.ARDY); // all ready?
//I2caRegs.I2CMDR.all = 0x2C20; // start, stop bit when CNT =0, master, rx, reset I2C 00101100
I2caRegs.I2CMDR.bit.NACKMOD = 0; // NACK mode bit
I2caRegs.I2CMDR.bit.FREE = 0; // Stop I2C when suspended
I2caRegs.I2CMDR.bit.STT = 1; // START condition bit
I2caRegs.I2CMDR.bit.STP = 1; // STOP condition bit
I2caRegs.I2CMDR.bit.MST = 1; // Master mode
I2caRegs.I2CMDR.bit.TRX = 0; // Receiver mode
I2caRegs.I2CMDR.bit.XA = 0; // 7-bit addressing mode
I2caRegs.I2CMDR.bit.RM = 0; // Nonrepeat mode
I2caRegs.I2CMDR.bit.DLB = 0; // Digital loopback mode is disabled
I2caRegs.I2CMDR.bit.IRS = 1; // The I2C module is enabled
I2caRegs.I2CMDR.bit.STB = 0; // The I2C module is not in the START byte mode
I2caRegs.I2CMDR.bit.FDF = 0; // Free data format mode is disabled
I2caRegs.I2CMDR.bit.BC = 0; // 8 bits per data byte
I2caRegs.I2CCNT = 1; // only read one byte data
if(I2caRegs.I2CSTR.bit.NACK == 1)
{
I2caRegs.I2CSTR.all = I2C_CLR_NACK_BIT; // 0x0002
}
I2caRegs.I2CMDR.bit.STP = 1; // stop bit when CNT=0
Lucky_value = I2caRegs.I2CDRR.bit.DATA;
i++;
When the breakpoint is placed next to the i ++ code line, the following result is observed:
If the breakpoint is not placed, the first images given is taken.


