Part Number: TMS320F28069
Tool/software: Code Composer Studio
I have a problem with I2C module on the TMS320F28069. In particular my code generate the start condition, the address of the slave (are present on the SDA pin), but doesn't generate the data bytes!!!!!!
My code snippet is the follow:
InitI2C(void)
{
I2caRegs.I2CSAR = 0x0069; // Slave address - EEPROM control code
I2caRegs.I2CPSC.all = 0x08; // 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.I2CMDR.all = 0x0020;
I2caRegs.I2CFFTX.all = 0x6000; // Enable FIFO mode and TXFIFO
}
Uint16 I2CA_WriteData(unsigned short slaveaddr, unsigned int length, unsigned char Data)
{
while (I2caRegs.I2CSTR.bit.BB != 0);
I2caRegs.I2CMDR.bit.MST=1;//Set to Transmit mode
while(I2caRegs.I2CMDR.bit.STP !=0); // 0-->STP is automatically cleared after the STOP condition has been generated.
I2caRegs.I2CSAR = slaveaddr; //0x69;// slave address
while (I2caRegs.I2CSTR.bit.BB != 0);
I2caRegs.I2CCNT = length;//Setup number of bytes to send
I2caRegs.I2CDXR =0xA5;
// Send start as master transmitter
I2caRegs.I2CSTR.bit.NACK = 1;
I2caRegs.I2CMDR.bit.FDF=0;
I2caRegs.I2CMDR.bit.TRX=1;
I2caRegs.I2CMDR.bit.BC = 0;
I2caRegs.I2CMDR.bit.STT=1;
I2caRegs.I2CMDR.bit.FREE=1;
// I2caRegs.I2CMDR.all=0x6E20; not used
while(I2caRegs.I2CSTR.bit.NACK == 0);
I2caRegs.I2CMDR.bit.STP = 1;
}
int main (){
InitI2C();
I2CA_WriteData(0x68,0x01,0x05);
}
this what am getting in the scope
*************
Thanking you,
Regards
Arjun k
:)
