This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM368 I2C loopback测试不通过



您好,我想初步测试一下I2C回环接口,设置模式寄存器DLB比特位,代码如下:

Int16 EVMDM368_I2C_loopback( Uint16 i2c_addr, Uint8* data, Uint16 len )

{

Int32 timeout, i;

I2C_ICCNT = len;                    // Set length

I2C_ICSAR = i2c_addr;               // Set I2C slave address

I2C_OAR = i2c_addr;

I2C_ICMDR = ICMDR_STT               // Set for Master Write

 | ICMDR_TRX

 | ICMDR_MST

 | ICMDR_DLB;

_wait( 10 );                        // Short delay

for ( i = 0 ; i < len ; i++ )

{

I2C_ICDXR = data[i];            // Write

timeout = 0x10000;

do

{

if ( timeout-- < 0  )

{

EVMDM368_I2C_reset( );

return -1;

}

} while ( ( I2C_ICSTR & ICSTR_ICXRDY ) == 0 );// Wait for Tx Ready

}

Uint8 data1[2];

   memset(data1,0,2);

   EVMDM368_waitusec(30);

//I2C_ICMDR = ICMDR_STT               // Set for Master Write

//  | ICMDR_MST;

   I2C_ICCNT = 1;

   data1[0] = I2C_ICDRR;

   printf("loopback receive %x\n",data1[0]);

   I2C_ICMDR |= ICMDR_STP;             // Generate STOP

while(I2C_ICSTR & 0x1000);

EVMDM368_waitusec(30);

return 0;

}

调用上面的函数发送一个字节0xaa,发送成功了,但是接收不到。请问什么原因??

请帮忙??谢谢!!