Other Parts Discussed in Thread: HALCOGEN
Hi
I hope you can help me in my software development by providing a sample code for i2cNotification(i2cBASE_t *i2c, uint32 flags)
I would like to test for noack for a bad IC or non existent IC. I would like to just send out an i2c slave address and wait for the noack. If there is acknowledge, I will then proceed with sending data. Below is the code for testing ack. I am using the bit TSS_bErrorIC to contain error/non error status. Please let me know if is correct. Thank you.
void TSS_vInit(){
// set registers for sending to TCN75
// set slave address
uint32_t delay = 0U;
i2cBASE_t *i2c=i2cREG2;
vGpioSetBit(N2HET1_27, 1); //use N2HET1[27] pin A9 as test output. Set it as output high
i2cClearSCD(i2c);
i2cSetSlaveAdd(i2c, TCN75_I2C_ADDR); // temp sensor is using i2c2
i2cSetMode(i2c, I2C_MASTER);
i2cSetDirection(i2c, I2C_TRANSMITTER);
/* Transmit Start Condition */
i2cSetStart(i2c);
TSS_bErrorIC=true;
for(delay=0;delay<100;delay++);
{
if((i2c->STR & I2C_NACK) != I2C_NACK)
{
TSS_bErrorIC=false;
}
}
i2cSetStop(i2c);
/* Wait until Bus Busy is cleared */
while(i2cIsBusBusy(i2c) == true);
/* Clear the Stop condition */
i2cClearSCD(i2c);
//vGpioSetBit(N2HET1_27, u8ReadGpioPinVal(N2HET1_27) ^ 1);
vGpioSetBit(N2HET1_27, 0);
//printf("TSS_vInit 2");
}



