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.

TMP117EVM: Writing data to the registers

Part Number: TMP117EVM
Other Parts Discussed in Thread: CC3220SF, TMP117, TIDA-01624

Hello,

I have the TMP117EVM linked to my CC3320SF board to read ambient temperatures in a room. I cannot seem to find a way to write the to the registers on the TMP117EVM using the I2C drivers provided in the CC3220SF SDK. Can someone help? 

I used this as a template to interface with the sensor:

http://dev.ti.com/tirex/#/?link=Software%2FSimpleLink%20CC32xx%20SDK%2FExamples%2FDevelopment%20Tools%2FCC3220SF-LAUNCHXL%2FTI%20Drivers%2Fi2ctmp006%2FTI-RTOS%2FCCS%20Compiler%2Fi2ctmp006

Snippet of my code:

/* setting the high limit temp */
HTWriteBuffer[0] = High_Lim_Reg;
HTWriteBuffer[1] = highliml;
HTWriteBuffer[2] = highlimh;
i2cTransaction2.slaveAddress = TMP117_address;
i2cTransaction2.writeBuf = HTWriteBuffer;
i2cTransaction2.writeCount = 2;
i2cTransaction2.readBuf = HTReadBuffer;
i2cTransaction2.readCount = 2;

^I am trying to write a 2 byte value to the High temp limit register and store the highest temp I want to see but when I read from the register to check if it was written correctly the value I sent is not returned and I get the default value of 8000h (0x8000).

  • Hello Chris,

    The correct method to write to the TMP117 using the SimpleLink MCU would be

    HTWriteBuffer[0] = High_Lim_Reg;
    HTWriteBuffer[1] = highliml;
    HTWriteBuffer[2] = highlimh;
    i2cTransaction2.slaveAddress = TMP117_address;
    i2cTransaction2.writeBuf = HTWriteBuffer;
    i2cTransaction2.writeCount = 3;
    i2cTransaction2.readBuf = HTReadBuffer;
    i2cTransaction2.readCount = 0;


    We have the reference design TIDA-01624 which uses the BLE MCU to write to the TMP117 and you may use it as a reference code.
  • Thank you for clarifying how to write the data now could you clarify how to read the data from this register. I though it would be similar to reading from the temperature register which was as follows:

    txBuffer[0] = Temp_Reg;
    i2cTransaction.slaveAddress = TMP117_address;
    i2cTransaction.writeBuf = txBuffer;
    i2cTransaction.writeCount = 1;
    i2cTransaction.readBuf = rxBuffer;
    i2cTransaction.readCount = 2;

    if (I2C_transfer(i2c, &i2cTransaction)) {
    temperature = (rxBuffer[0] << 8) | (rxBuffer[1]);
    temp_p = temperature * 0.0078125; ;
    Display_printf(display, 0, 0, "Temperature is: %0.1f [C]", temp_p);
    }



    what i wrote:

    txBuffer[0] = High_Lim_Reg;
    txBuffer[1] = highliml;
    txBuffer[2] = highlimh;
    i2cTransaction2.slaveAddress = TMP117_address;
    i2cTransaction2.writeBuf = txBuffer;
    i2cTransaction2.writeCount = 3;
    i2cTransaction2.readBuf = rxBuffer;
    i2cTransaction2.readCount = 2;

    if (I2C_transfer(i2c, &i2cTransaction2)){
    high_temp = (rxBuffer[0]) << 8 | (rxBuffer[1]);
    Htemp_p = high_temp * 0.0078125;
    Display_printf(display, 0, 0, "High is: %0.1f [C]", Htemp_p);
    }

    Unfortunatley I am not getting the value I am storing which would be 24 degrees C which in binary would be:
    24 degrees C = 0000 1100 0000 0000
    according to the data sheet. the number I am getting is 0.5 which is:
    0000 0000 0100 0000





    Calculation used to determine binary number based on TMP117 data sheet:
    Temp desired / 0.0078125 = binary of that temperature
  • Hello Christopher,

    I don't have a setup to test it out, but it should look something like the following

    txBuffer[0] = High_Lim_Reg;
    txBuffer[1] = highliml;
    txBuffer[2] = highlimh;
    i2cTransaction2.slaveAddress = TMP117_address;
    i2cTransaction2.writeBuf = txBuffer;
    i2cTransaction2.writeCount = 3;
    i2cTransaction2.readBuf = rxBuffer;
    i2cTransaction2.readCount = 0;

    I2C_transfer(i2c, &i2cTransaction2);

    txBuffer[0] = High_Lim_Reg;
    i2cTransaction2.slaveAddress = TMP117_address;
    i2cTransaction2.writeBuf = txBuffer;
    i2cTransaction2.writeCount = 1;
    i2cTransaction2.readBuf = rxBuffer;
    i2cTransaction2.readCount = 2;

    if (I2C_transfer(i2c, &i2cTransaction2)) {
    high_temp = (rxBuffer[0]) << 8 | (rxBuffer[1]);
    Htemp_p = high_temp * 0.0078125;
    Display_printf(display, 0, 0, "High is: %0.1f [C]", Htemp_p);
    }