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.

TMS320F28379D: TMS320F28379D interface with BQ32000

Part Number: TMS320F28379D

Tool/software:

I'm trying to interface with BQ 32000, address is not writing properly,

address I'm writing 0xD0, but address sending is 0x0A with W/R 

please suggest what I'm doing wrong here.

void I2c_GPIO(){

EALLOW;

GpioCtrlRegs.GPCGMUX2.bit.GPIO92 = 1; // I2c RTC_SCL-A
GpioCtrlRegs.GPCGMUX2.bit.GPIO91 = 1; // I2c RTC_SDA-A

GpioCtrlRegs.GPCMUX2.bit.GPIO92 = 2; // I2c RTC_SCL-A
GpioCtrlRegs.GPCMUX2.bit.GPIO91 = 2; // I2c RTC_SDA-A

GpioCtrlRegs.GPCPUD.bit.GPIO92 = 0; // I2c RTC_SCL-A
GpioCtrlRegs.GPCPUD.bit.GPIO91 = 0; // I2c RTC_SDA-A

GpioCtrlRegs.GPCQSEL2.bit.GPIO92 = 3; // I2c RTC_SCL-A
GpioCtrlRegs.GPCQSEL2.bit.GPIO91 = 3; // I2c RTC_SDA-A

GpioCtrlRegs.GPCGMUX2.bit.GPIO90 = 1; //I2c RTC_IRQ
GpioCtrlRegs.GPCMUX2.bit.GPIO90 = 2; // I2c RTC_IRQ
GpioCtrlRegs.GPCPUD.bit.GPIO90 = 0; // I2c RTC_IRQ
GpioCtrlRegs.GPCDIR.bit.GPIO90 = 0;
GpioCtrlRegs.GPCQSEL2.bit.GPIO90 = 3; // I2c RTC_IRQ

EDIS;
}

//
// I2CA_Init - Initialize I2CA settings
//

void RTC_I2CA_Init(void)
{

EALLOW;

I2caRegs.I2CMDR.bit.IRS = 0;
I2caRegs.I2CPSC.all = 8; // Prescaler - need 7-12 Mhz on module clk (200/16+1 = 11Mhz)
I2caRegs.I2CCLKL = 49; // NOTE: must be non zero
I2caRegs.I2CCLKH = 49; // NOTE: must be non zero
// I2caRegs.I2CIER.all = 0x1A; // Enable SCD & ARDY __interrupts
// I2caRegs.I2CSTR.all = 0xFF;// Enable interrupts
I2caRegs.I2CIER.all = 0x24; // Enable SCD & ARDY interrupts
I2caRegs.I2CMDR.all = 0x0020; // Take I2C out of reset
I2caRegs.I2CMDR.bit.XA = 0;

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

EDIS;

return;
}

//
// I2CA_WriteData - Transmit I2CA message
//
Uint16 I2CA_WriteData()
{
int i=0;
//
// 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.
//
I2caRegs.I2CMDR.bit.IRS = 1; //reset
//
// Setup slave address
//
I2caRegs.I2CMDR.bit.MST = 1; // module salect as as master
I2caRegs.I2CMDR.bit.TRX = 1; // TX mode
if(I2caRegs.I2CMDR.bit.STP == 1)
{

}
if(I2caRegs.I2CSTR.bit.BB == 1)
{

// return I2C_BUS_BUSY_ERROR;
}
I2caRegs.I2CSAR.bit.SAR = write_address_slave;
//
// Setup number of bytes to send
// MsgBuffer + Address
//
I2caRegs.I2CCNT = 0x05;

I2caRegs.I2CMDR.bit.STT = 1; // start comunications to take control on line

I2caRegs.I2CDXR.bit.DATA = 0x00;
I2caRegs.I2CDXR.bit.DATA = 0x20;
I2caRegs.I2CDXR.bit.DATA = 0x30;

I2caRegs.I2CMDR.bit.STP == 1;

return I2C_SUCCESS;
}