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.

TMP112: it is right to run shut down mode ?

Part Number: TMP112


first step

#if 1
    printf("ti configure\n");
    
    TMP_WriteConfReg(0x61a0);
    delay_ms(35);
    conf_value = TMP_ReadConfReg();
    printf("config value %u\n", (unsigned int)conf_value);
    
    #endif

then

float tmp112_get(void)
{
    uint16_t sensor_data = 0;
    float sensor_temp = 0;
    uint16_t conf_value = 0;
    
    TMP_WriteConfReg(0xe1a0);
    
    #if 0
    delay_ms(2);
    conf_value = TMP_ReadConfReg();
    printf("in measure config value %u\n", (unsigned int)conf_value);
    #endif
    
    delay_ms(30);
    conf_value = TMP_ReadConfReg();
    if((conf_value & 0x8000) == 0x8000)
    {
        printf("*config value %x\n", conf_value);
    }
    else
    {
        printf("convert dont complete\n");
        delay_ms(5);
    }
    
    
    sensor_data = TMP_ReadTemp();
    //printf("data %u\n", sensor_data);
    sensor_temp = (short int)sensor_data / 16 * 0.0625;
    printf("the data is %f\n", sensor_temp);
    
    
    return sensor_temp;
}

  • Hi,

    Welcome to the E2E Forums, and thank you for your question.

    Your code looks like it will work. You are writing the correct values to the configuration register for initiating shutdown and triggering 1 shot measurements.

    Does the TMP_ReadTemp() function return the raw 16 bit value of the temperature register? If so then this conversion method will work as well. 

    Best Regards,
    Brandon Fisher