Tool/software: Code Composer Studio
now, i am using the tms320f28069 i want to communicate to slave through the i2c without fifo register.
the code which i am using is
init i2c
void
InitI2C(void)
{
I2caRegs.I2CSAR = 0x0068; // Slave address - EEPROM control code
I2caRegs.I2CPSC.all = 0x08; // Prescaler - need 7-12 Mhz on module clk
I2caRegs.I2CCLKL = 10;//155-->50khz// 60-100kzh //10; 400khz // NOTE: must be non zero
I2caRegs.I2CCLKH = 05;//65-->50Kzh//30-100khz//5; 400khz // NOTE: must be non zero
I2caRegs.I2CIER.all = 0x24; // Enable SCD & ARDY interrupts
I2caRegs.I2CMDR.all = 0x0020;
// I2caRegs.I2CFFTX.all = 0x6000; // Enable FIFO mode and TXFIFO
//I2caRegs.I2CMDR.all=0x6E20;
// I2caRegs.I2CFFRX.all = 0x2040; // Enable RXFIFO, clear RXFFINT,2040
I2caRegs.I2CMDR.bit.IRS= 1;
}
write i2c
void I2CA_WriteData_1(unsigned short reg, unsigned short data)
{
while (I2caRegs.I2CSTR.bit.BB == 1);
I2caRegs.I2CCNT = 2; //Setup number of bytes to send
I2caRegs.I2CDXR = reg;
I2caRegs.I2CMDR.all = 0x6620;
I2caRegs.I2CDXR = data;
I2caRegs.I2CMDR.all = 0x6E20;
while (I2caRegs.I2CSTR.bit.SCD == 0) ;
}
reading i2c\
void I2CA_ReadData5( Uint16 reg, Uint16 readCount, Uint8 *buffer)
{
Uint16 i;
// delay_loop();
// I2CA_WriteData_1(0x68, 0x04);
delay_loop();
I2CA_WriteData_1(0x6A, 0x45);
while (I2caRegs.I2CSTR.bit.BB == 1);
I2caRegs.I2CCNT = 1; //Setup number of bytes to send
I2caRegs.I2CDXR = reg;
I2caRegs.I2CMDR.all = 0x6620;
// I2caRegs.I2CDXR=data;
// I2caRegs.I2CMDR.all=0x6E20;
// while (I2caRegs.I2CSTR.bit.BB == 1);
while (I2caRegs.I2CMDR.bit.STP !=0);
delay_loop();
// I2caRegs.I2CCNT = 4; //Setup number of bytes to send
// buffer=I2caRegs.I2CDRR;
// I2caRegs.I2CMDR.all=0x6C20;
// while(I2caRegs.I2CSTR.bit.SCD == 0);
I2caRegs.I2CCNT = 4; // only read one byte data
// while(!I2caRegs.I2CSTR.bit.ARDY);
if (I2caRegs.I2CSTR.bit.NACK == 1)
{
I2caRegs.I2CSTR.all = I2C_CLR_NACK_BIT; // 0x0002
}
I2caRegs.I2CMDR.bit.STP = 0; // stop bit when CNT=0
while (!I2caRegs.I2CSTR.bit.SCD); // stop bit detected?
for (i = 0; i < 4; i++)
{
buffer[i] = I2caRegs.I2CDRR; // read one byte data
}
I2caRegs.I2CMDR.all = 0x6C20;
while (I2caRegs.I2CSTR.bit.SCD == 0);
}
please tell me the problem where i did the mistake .....