Hi,all
Today,Iwant to test the AIC3106 in my DM8168evm is ok or not. I use the test code AIC3106 that spectrum digital evm8168 provided.(Website:http://support.spectrumdigital.com/boards/evm816x/revg/)。I can not hear the Audio loopback sound and 1kHz sine sound,Then i run the code step by step,then I find the problem,but I do not know how to solve。
The problem is as follow:when the program run tu the last line in AIC3106.c(return EVM816X_I2C0_write( AIC3106_I2C_ADDR, cmd, 2 );),then it comes to the function EVM816X_I2C0_write() in evm816x_i2c.c,the problem will come. The function EVM816X_I2C0_write() code is as follow:
Uint16 EVM816X_I2C0_write( Uint16 slave_addr, Uint8* data, Uint16 length )
{
Uint8 *pdata = ( Uint8 * )data;
Uint8 last_byte = ( data[length-1] & 0xFF );
Uint16 status;
Int16 i, timecount, timeout = 0x1000;
/* Set slave address */
I2C0_SA = slave_addr;
/* Set data count */
I2C0_CNT = length;
/* Poll BB field on I2C0_STAT - Wait for bus to become free */
for ( i = 0 ; I2C0_STAT & I2C_STAT_BB ; i++ )
if ( i > timeout )
return 2001;
/* Configure Options for Transmitting - Master Transmit mode */
I2C0_CON = 0
| I2C_CON_I2C_EN // I2C Enable
| I2C_CON_MST // Master Mode
| I2C_CON_TX // Transmit Mode
| I2C_CON_STP // Stop
| I2C_CON_STT // Start
;
/* Poll until complete */
for ( timecount = 0 ; timecount < timeout ; timecount++ )
{
/* Read I2C Status register */
status = I2C0_STAT;
// MY NOTE: when it come here,it can not go to the follow function.Then it will be time out. Why,how to solve?
/* Check for NACK */
if ( ( status & I2C_STAT_NACK ) != I2C_STAT_NACK )
{
/* Check for ARDY */
if ( ( status & I2C_STAT_ARDY ) != I2C_STAT_ARDY )
{
/* Check for XRDY */
if ( ( status & I2C_STAT_XRDY ) == I2C_STAT_XRDY )
{
/* Send Data */
if ( length == 1 )
{
I2C0_DATA = last_byte;
length--;
}
else
{
I2C0_DATA = *pdata++;
length -= 1;
}
/* Clear Transmit Ready field */
I2C0_STAT &= I2C_STAT_XRDY;
}
}
....
....
//I2C0_CON |= 0x02;
_wait( 1000 );
}
}
/* I2C Timeout */
return 2002;
}
The problem is that when it come to
/* Read I2C Status register */
status = I2C0_STAT;
Then follow code,it will not execute until timeout,why??where is my problem lies??How to solve??Besides,what is I2C0_STAT register means??
Thanks in advance,
Zhao