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.

TMS570LC4357: Sample code for void i2cNotification(i2cBASE_t *i2c, uint32 flags)

Part Number: TMS570LC4357
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");


}

  • Hi LayEng,

    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.

    This is the behavior you observe when you don't enable the ignore NACK in HALCoGen

    If we don't enable this one then master will not send any data if it won't get ACK for slave address.

    Example:

    If you see my code i am sending 0x57 slave address and after that i am try to send 0x10 data byte

    This is the waveform i got when i disable the ignore NACK option.

    See master not sending data byte due to not getting ACK from slave.

    This is the waveform i got when i enable the ignore NACK option.

    As you can see, here master sending data byte irrespective of ACK state.

    --

    Thanks & regards,
    Jagadish.