LPC1343的DEMO程序在多字节传输的时候校验不正确,
请各位大虾看看
int main (void)
{
uint32_t i;
SystemInit();
UARTInit(115200);
printf("\n\r-- I2C Read/Write EEPROM test -- \n\r");
if ( I2CInit( (uint32_t)I2CMASTER ) == FALSE )
{
while ( 1 );
}
I2CWriteLength = 6;
I2CReadLength = 0;
I2CMasterBuffer[0] = PCF8594_ADDR;
I2CMasterBuffer[1] = 0x00; /* address */
I2CMasterBuffer[2] = 0x55; /* Data0 */
I2CMasterBuffer[3] = 0xAA; /* Data1 */
I2CMasterBuffer[4] = 0x12; /* Data0 */
I2CMasterBuffer[5] = 0x34; /* Data1 */
I2CEngine();
for ( i = 0; i < 0x20000; i++ ); /* Delay after write */
for ( i = 0; i < I2C_BUFSIZE; i++ )
{
I2CSlaveBuffer[i] = 0x00;
}
/* Write SLA(W), address, SLA(R), and read one byte back. */
I2CWriteLength = 3;
I2CReadLength = 4;
I2CMasterBuffer[0] = PCF8594_ADDR;
I2CMasterBuffer[1] = 0x00; /* address */
I2CMasterBuffer[2] = PCF8594_ADDR | RD_BIT;
I2CEngine();
// for (i = 0; i < 3; i++ )
// {
if (I2CSlaveBuffer[i] != I2CMasterBuffer[i+3])
{
ErrorCount++;
}
// }
if (ErrorCount)
{
printf("\n\r I2C EEPROM test failed! \n\r");
}
else
{
printf("\n\r I2C EEPROM test success!\n\r");
}
return 0;
} |