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.

MSPM0G3507: MSPM0G3507

Part Number: MSPM0G3507

Tool/software:

Hi TI Team.

I am working on MSPM0g3507 controller with interfacing i2c sensors those are SHT35 and HS300, before taking data from that sensor I want to probe and check if the sensor is present or not,

I have set the sensor addresses as 0x45 and 0x44 respectively.

i need to write the address and read the ACK from the sensor. so which driver function should I use that can capture and return ACK 

so can use that ACK for probing sensor presence?

regards 

Prajesh karmalkar

  • Hi Prajesh, you can use a logic analyzer as one option to ensure that the ACK is returned and correct. If this is something you want to implement in code, you can use Section 18.2.3.4 in the technical reference manual which outlines the ACK/NACK. It looks like the I2C data format includes the ACK/NACK so you should be able to pull this from this specific bit location as well.

    -Brian

  • probe means, i want to probe the sensor using firmware , is there any function in the TI library or driver that returns ACK .so I can use that ACK to confirm which sensor is present so I can take ACK from that sensor.

    actually, I want sensor ack, so I know I have the correct sensor.

    • true: The I2C transaction completed successfully. This means the device at the specified address (in this case, the SHT35) acknowledged the communication.
    • false: The I2C transaction failed. This could indicate that the device did not acknowledge the address or there was an issue on the I2C bus.

    Example 

    if (I2C_transfer(i2c, &i2cTransaction))
    {
        // If true, the sensor acknowledged its address.
        printf("SHT35 is active and responded to the address.\n"); }
    else
    {
        // If false, the sensor did not acknowledge.
        printf("SHT35 did not respond to the address. Check wiring and power.\n");
    }
  • like the above i2c_transfer function which returns.

  • I don't see a DriverLib function to do the kind of probe you're looking for, so I suspect you'll have to write it yourself.

    What you're looking for is a "Quick Command".  [Ref TRM (SLAU846A) Sec 18.2.4.1.1, down near the end.] This is just a transaction with START+STOP, with a length of 0. It can be a read or a write; typically this kind of probe would be done with a read, but (see below) you'll probably have to use a write.

    I don't use DriverLib, but I think you could do such a probe with something like (untested):

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    DL_I2C_startControllerTransferAdvanced(I2C_n_INST, Target_I2C_Addr,
    DL_I2C_CONTROLLER_DIRECTION_TX,
    0u, // Length=0
    DL_I2C_CONTROLLER_START_ENABLE,
    DL_I2C_CONTROLLER_STOP_ENABLE ,
    DL_I2C_CONTROLLER_ACK_DISABLE);
    uint32_t msr;
    do {
    msr = DL_I2C_getControllerStatus(I2C_n_INST);
    } while ((msr & I2C_MSR_IDLE_SET) == 0);
    uint32_t OK = 1;
    if (msr & I2C_MSR_ERR_SET)
    OK = 0;
    return(OK);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I think you'll need to use a write since:

    1) The SHT35 will NACK if it gets a read request and it doesn't have data ready [Ref SHT35 datasheet (rev 7) Sec 4.6], so the result is ambiguous.

    2) Erratum I2C_ERR_02 puts significant restrictions on a quick command as a read.

    You may want to check the HS300 to see if you have any reservations about sending an (empty) write.

    Let us know how it turns out.

  • Hi , i have checked this implementation as well, but my only simple requirement is I just want to check whether my target sensor send ack to address or not. i am a little bit confused in the naming used in SDK for the target (i think the target in SDK is for MSPM0 when it is configured to use as target/i2c slave). 

  • how DL_I2C_startControllerTransferAdvanced or DL_I2C_startControllerTransfer handle ack receive from slave device (in my case from sensor)?

  • Those functions only start the transaction; you have to wait for it to complete. For a 0-length transaction, it will complete after the address (SLA) byte in either case (ACK or NACK).

    In addition to the ERR bit, the MSR also has an ADRACK bit which is =1 if it saw a NACK on the SLA byte. [My driver uses RIS.MNACK instead, but I didn't find an easy way to get that from DriverLib.]