Dear all:
I have I2C test program (basically it's from spectrum digital's example ) runs on DSP of omapl137, it never send data successfully, can someone help me to see what's happened.
I used I2C0 and pinmux8 set as 0x28822111 (for I2C0_SCL, I2C0_DAT) via AISGen tool, that is the test program is as AIS format file, all PSCs are enabled. system clock is set as 24M Hz crystal, CPU 300 MHz. EMIFA 100MHz, EMIFB 300MHz.
Since I2C0 clock input is auxclk, and MDIO test program is OK (which use auxclk also), I assume the auxclk is enabled when program runs.
I want to use I2C0 to act as master transmit mode. Below is my init code for I2C0:
/* 24M Hz I2C input clock, I2C system clock 8M Hz, I2C 40Kbits/sec */
I2C_ICMDR = 0;
I2C_ICPSC = 2;
I2C_ICCLKL = 95;
I2C_ICCLKH = 95;
while(I2C_ICIVR != 0) I2C_ICIVR;
I2C_ICSTR = I2C_ICSTR;
I2C_ICMDR = 0 | ICMDR_FREE
| ICMDR_STT
| ICMDR_STP
| ICMDR_MST // master mode
| ICMDR_TRX; // transmit mode
I2C_ICMDR |= ICMDR_IRS; // Release I2C0 from reset
After init routine, I try to transmit data, but I get time-out message. I can't see clock signal from the scope during program runs, below is the code for transmit:
I2C_ICCNT = len;
I2C_ICSAR = i2c_addr;
for ( i = 0 ; i < len ; i++ )
{
while(I2C_ICIVR != 0) I2C_ICIVR;
I2C_ICSTR = I2C_ICSTR;
I2C_ICDXR = data[i];
timeout = i2c_timeout;
do
{
if ( timeout-- < 0 )
{
EVMOMAPL137_I2C_reset( );
return -1;
}
} while ( ( I2C_ICSTR & ICSTR_ICXRDY ) == 0 );
}
The routine always time out and have no clock, data send out, can someone tell me what's wrong, or what can I check to fix the problem?