Part Number: TMS320F28377S
Tool/software: Code Composer Studio
Dear Sir,
I am trying to use I2C on tms320f28377s, GPIO91 and GPIO92 (I2C A). But this is not working. This is my code. There is no clock or output on this pin.So please help me to find out what is wrong.
/* Initialisation , i take this form example code given in control suit */
void I2CA_Init(void)
{
GpioCtrlRegs.GPCMUX2.bit.GPIO91=6;
GpioCtrlRegs.GPCMUX2.bit.GPIO92=6;
//GPIO_SetupPinMux(91, GPIO_MUX_CPU2,6);
//GPIO_SetupPinMux(92, GPIO_MUX_CPU2,6);
I2caRegs.I2CSAR.all = 0x00A0; // Slave address - EEPROM in write mode
I2caRegs.I2CPSC.all = 6; // Prescaler - need 7-12 Mhz on module clk
I2caRegs.I2CCLKL = 10; // NOTE: must be non zero
I2caRegs.I2CCLKH = 5; // 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,
return;
}
void I2CA_WriteData(void)
{
unsigned char 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.
//
check1:
if(I2caRegs.I2CMDR.bit.STP == 1)
{
goto check1;
// return I2C_STP_NOT_READY_ERROR;
}
//
// Setup slave address
//
I2caRegs.I2CSAR.all = 0XA0; //eeprom address.
//
// Check if bus busy
//
if(I2caRegs.I2CSTR.bit.BB == 1)
{
//return I2C_BUS_BUSY_ERROR;
goto check1;
}
//
// Setup number of bytes to send
// MsgBuffer + Address
//
I2caRegs.I2CCNT = 2;
//
// Setup data to send
//
// I2caRegs.I2CDXR.all = 0X00;
I2caRegs.I2CDXR.all = 0XAA;
//
// Send start as master transmitter
//
I2caRegs.I2CMDR.all = 0x6E20;
return ;
}