Hi all,
please look at this piece of code:
static U16 TouchHal_Read( void )
{
uint32_t uTmpBuff1 = 0;
uint32_t uTmpBuff2 = 0;
U16 ret = 0;
I2CMasterSlaveAddrSet( I2C_FAST_TOUCH_IF, TOUCH_HAL_SLAVE_ADDRESS, true );
I2CMasterControl( I2C_FAST_TOUCH_IF, I2C_MASTER_CMD_SINGLE_RECEIVE );
while( I2CMasterBusy( I2C_FAST_TOUCH_IF ) );
// please see below....
uTmpBuff1 = I2CMasterDataGet( I2C_FAST_TOUCH_IF );
uTmpBuff1 = uTmpBuff1 & 0x000000FF;
ret = (U16)(uTmpBuff1 | uTmpBuff2);
}
I've observed that there's a mismatch beetwen the content of register I2C_O_SDR and the SRAM content of uTmpBuff1.
To demonstrate this issue I've done a simple timer task that read alternativelly TEMP0 and TEMP1 of TSC2007 but instead of read TEMP0 and then TEMP1 I read TEMP1 and TEMP0.
In order to fix this issue I put a small delay :
...
while( I2CMasterBusy( I2C_FAST_TOUCH_IF ) );
SystemDelayMicroSecond( 250 );
uTmpBuff1 = I2CMasterDataGet( I2C_FAST_TOUCH_IF );
...
In my opinon it seems that I2CMasterDataGet is called to fast respect the I2CMasterBusy but I don't understand completely the issue.
Any suggestion?
Thanks, regards,
Marco Crivellari