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.

MSP432P401R: Master (MSP432) I2C driver: How to verify whether master has got ACK from slave or not?

Part Number: MSP432P401R

Hello All,

I have a requirement where I need to verify the I2C bus interface functionality with the slave device.

I am configuring EUSCI_B0_BASE as I2C master to communicating with slave. I have the below code for I2C configuration,

MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN6 + GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION);

/* Initializing I2C Master to SMCLK at 100khz with no autostop */
MAP_I2C_initMaster(EUSCI_B0_BASE, &i2c1Config);

/* Specify slave address */
MAP_I2C_setSlaveAddress(EUSCI_B0_BASE, I2C_INTERFACE_1_SLAVEADDRESS);

/* Enable I2C Module to start operations */
MAP_I2C_enableModule(EUSCI_B0_BASE);

Once after enabling i2C module, I need to check whether master received ACK from slave or not. from the datasheet I have found, " If the slave does not acknowledge the transmitted address, the not-acknowledge interrupt flag UCNACKIFG is set". From this I came to know, I can track at least the slave NACK instead of ACK. For this I have below check,

if ((UCB0IFG & UCNACKIFG) == 0) // Check for slave NACK.
{
// I2C slave responded. Get data.}

else{

      // I2C slave did not respond.}

But, in my case where no Slave is connected the first check is getting passed as default values are set here.

Can someone help me to understand, whether UCNACKIFG will not be set if no slave is connected ? In that case, how to validate whether slave connected or not?

  • Part Number: MSP432P401R

    Hello,

    I am using I2C driver from no-rtos API's. As per the i2c.h header  file defined in driverlib file, there are multiple API's provided for single bye or multi-byte transfer and receive operations.

    But in my case, I am having below read sequence from slave device (HDC2010) where I want to read the Manufacturer ID(address is 0xFC).

    My query is, in the list of API's for I2C, I din't find any API's which can be used for this opearation.

    Can someone help me to find the right source of API's with logic to achieve this?

  • Hi,

    We will look into it and get back to you ASAP.

    Thanks,

    PM

  • Hi Tajpeer,

    I think you should take a look to following code example from the resource explorer. It sends 2 bytes to the slave and reads one afterwards. So with small modifications you should be able to realize the protocol you mentioned above.

    i2c_master_rw_repeated_start_single_byte-slave_code_MSP_EXP432P401R_nortos_ccs

    The NACK should work as you described it should be set if the slave sends a NACK. To be honest I'm not sure how the I2C bus behaves if no slave is connected at all. Maybe some scope traces for analysis would help here.

    Alternatively you also can use the "I2C_transferTimeout" function from the driver lib and implement it into the example above.

    Hope this helps.

  • An I2C NACK is simply the absence of an ACK. If there's no slave at all on the bus (but the pullups are present) the master will see a NACK for any address.

  • Hi Tajpeer,

    it has been a while since our last response.

    Could you give us an update on the status.

    Could the above information help to solve the issues?

    Thanks

    Regards

    Kostas

**Attention** This is a public forum