Hello,
we using a TMS320F28069 with an I2C IO-Expander.
Sometimes we have problems with the I2C interface. It seems that the FIFO is overflowing.
The value 0x09 and value (mostly 0x1C) should be sent. In the code the value 0x09 is always sent first (register of the IO expander).
We see with the LogicAnalyzer that values are sent in the wrong order (see screenshot).
Config: void InitI2C ( void ) { I2caRegs.I2CSAR = I2C_SLAVE_ADDR; // (0x20) I2caRegs.I2CPSC.all = 8; // Prescaler - 10MHz I2caRegs.I2CMDR.bit.IRS = 1; // The prescaled frequency takes effect only when IRS is changed to 1. I2caRegs.I2CCLKL = 7; // NOTE: must be non zero I2caRegs.I2CCLKH = 7; // NOTE: must be non zero // --> 100.44 kHz I2C Speed I2caRegs.I2CFFTX.all = 0x6000; // Enable FIFO mode and TXFIFO I2caRegs.I2CFFRX.all = 0x2040; // Enable RXFIFO, clear RXFFINT } Function: int16 write_I2c_data ( unsigned int slave_addr, unsigned int length, unsigned char I2CRegister, unsigned char Value ) { int16 retval = 1; retval = check_BB_bit (I2C_TIMEOUT); if (retval < 0) { I2caRegs.I2CMDR.bit.IRS = 0; // Timed out. Reset module. I2C_ Errorhandling (); return retval; // Abbrechen } /***************Write******************/ I2caRegs.I2CSAR = slave_addr; // Setup slave address I2caRegs.I2CCNT = length; // Setup number of bytes to send MsgBuffer + Address I2caRegs.I2CDXR = I2CRegister; I2caRegs.I2CDXR = Value; // Send start as master transmitter I2caRegs.I2CMDR.all = 0x6E20; //gesetzt werden FREE, STT, STP, MST, TRX, IRS // -->> -- I2CMaster_Wait retval |= check_STP_and_BB_bit ( I2C_TIMEOUT); if (retval < 0) { I2caRegs.I2CMDR.bit.IRS = 0; // Timed out. Reset module. I2C_Errorhandling(); return retval; // Abbrechen } //--<<--- return retval; }
Call:
write_I2c_data ( I2C_SLAVE_ADDR, 2, MCP23008_GPIO, GPIO_exp.all );
This function is called very quickly.
Are overflows of the Send FIFO known?
How can I debug this exactly?
Thank you.
Markus