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.

Compiler/TMP102: Using TMP102 with MSP430fr6989

Part Number: TMP102

Tool/software: TI C/C++ Compiler

With TMP102 sensor, when I set sensor into Shut-Down mode and immediately read the configuration register, the One-Shot (OS) mode is also set by the sensor. I don’t know why sensor sets OS mode bit, nor does it reads temperature as stated in the temperature, nor can’t I find in the manual that describes this awkward phenomenon. Is this a defective sensor, or am I not interpreting user’s manual correctly. Also, I cannot communicate on high-speed I2C, only but sensor only allows me to communicate with sensor if I drop I2C clock to 100 KHz. I’m using MSP340FR6989 device, CCS6.2 with the assistance from TI’s driver library, eusci_b_i2c library. Why is it doing this?

  • Hi Kwang,

    The sensor needs 26ms (typ) to measure temperature. You will need to delay your MCU by at least this amount of time after writing SD/OS and reading the temperature result. Otherwise, the data in the temperature register will be from the last time a measurement was completed.

    7.4.3 is the section which describes OS bit operation. It states:

    During the conversion, the OS bit reads 0. The device returns to the SHUTDOWN state at the completion of the single conversion. After the conversion, the OS bit reads 1.

    Conversion is another word that means temperature measurement in the context of our sensor. 

    The device supports I2C FS (Fast Mode) up to 400KHz and I2C HS (High Speed) up to 2.85MHz. HS mode requires an HS command be sent.

    thanks,

    ren

  • I apologize the not being too clear.

    In the power up process, I’m initializing the sensor to disabling it. This is before my first attempt to read temperature sensor. I repeatedly send word to configuration register and read back; and sensor returns with OS (one-shot) bit set to HIGH. According to manual, I need to disable sensor before I set to OS to read temperature if I do not want sensor to in continual read mode. You’re welcome to view my codes sent to you offline for your review. I can’t copy and paste my code here due to size of coding and that I have several library of my own that is crazy to tying to copy and paste in the text box.

  • this is what I do in the main 

    void main(void)

    {

       Init_GPIO();

       Init_Sys_Clock();

           Init_Timer_A1(); 

           #if defined(UART_A0_SERIAL_COMMUNICATION) || defined(UART_A1_SERIAL_COMMUNICATION)

                  UART_Init();

                  // test UART communication

                  UART_transmitString(szTitleText);

                  __delay_cycles(5000000);

                  //delay_mSec(5000);

                  // clear screen

                  UART_transmitString("\ec");

           #endif

     

           #ifdef BUILTIN_LCD_DISPLAY

                  LCD_Init();

           #endif

     

           #ifdef I2C_SENSOR_ATTACHED

                  Init_TMP102();

           #endif

     

       while(1)

       {

          // set to LPM3 mode, enable interrupt

           __bis_SR_register(LPM3_bits + GIE);

     

           if (temperature_Read_OneShot == true)

           {

                 temperature_Read_OneShot = false;

                 set_TMP102_OneShot_Read();

                 __delay_cycles(50000);

                 displayTemperature();

           }

       }

    }

    and in separate TMP102 class library.

    void Init_TMP102()
    {
    config_TMP102.high_temp_limit = setTemperatureLimit(TEMP_ALERT_HIGH_LIMIT, TEMP_HIGH_LIMIT_REGISTER);

    config_TMP102.low_temp_limit = setTemperatureLimit(TEMP_ALERT_LOW_LIMIT, TEMP_LOW_LIMIT_REGISTER);

    setTMP102Configuration();

    }

    void setTMP102Configuration(void)
    {
    short dataWrite = 0;
    bool reqdUpdate = false;
    uint8_t conversionRate_local;

    dataWrite = read_Configuration_Register();

    #ifdef ENABLE_SHUT_DOWN_MODE
    if (config_TMP102.shut_down_mode == 0)
    {
    reqdUpdate = true;
    dataWrite = dataWrite | SHUT_DOWN_MODE_BIT_SET;
    }
    #else
    if (config_TMP102.shut_down_mode == 1)
    {
    reqdUpdate = true;
    dataWrite = dataWrite & ~SHUT_DOWN_MODE_BIT_SET;
    }
    #endif

    #ifdef ENABLE_INTERRUPT_MODE
    if (config_TMP102.thermostat_mode == 0)
    {
    reqdUpdate = true;
    dataWrite = dataWrite | THERMOSTAT_MODE_BIT_SET;
    }
    #else
    if (config_TMP102.thermostat_mode == 1)
    {
    reqdUpdate = true;
    dataWrite = dataWrite & ~THERMOSTAT_MODE_BIT_SET;
    }
    #endif

    #ifdef ALERT_ACTIVE_HIGH
    if (config_TMP102.polarity == 0)
    {
    reqdUpdate = true;
    dataWrite = dataWrite | POLARITY_MODE_BIT_SET;
    }
    #else
    if (config_TMP102.polarity == 1)
    {
    reqdUpdate = true;
    dataWrite = dataWrite & ~POLARITY_MODE_BIT_SET;
    }
    #endif

    #ifdef ENABLE_ONE_SHOT_MODE
    if (config_TMP102.one_shot_mode == 0)
    {
    reqdUpdate = true;
    dataWrite = dataWrite | ONE_SHOT_MODE_BIT_SET;
    }
    #else
    if (config_TMP102.one_shot_mode == 1)
    {
    reqdUpdate = true;
    dataWrite = dataWrite & ~ONE_SHOT_MODE_BIT_SET;
    }
    #endif

    switch (CONVERSION_RATE)
    {
    case 0:
    conversionRate_local = 0;
    break;
    case 1:
    conversionRate_local = 1;
    break;
    case 4:
    conversionRate_local = 2;
    break;
    case 8:
    conversionRate_local = 3;
    break;
    default:
    break;
    }

    if (config_TMP102.conversion_rate != conversionRate_local)
    {
    reqdUpdate = true;
    //x= conversionRate_local <<6
    dataWrite = (dataWrite & 0xff3f) | (conversionRate_local <<6);

    }

    if (reqdUpdate)
    writeTwoByte(TMP102_I2C_ADDRESS, TMP102_CONFIG_REGISTER, &dataWrite);

    short dataRead = read_Configuration_Register();

    }

  • Hi Kwang,

    I'm sorry, but i won't be able to review all of your source code. If you would like to use the One Shot feature, I would recommend you structure your code like this:

    initialize:

    write to config register with SD=1

    read:

    write to config register with SD=1 and OS=1

    wait 35ms

    write pointer temp reigster, read 2 bytes

    You may perform read function in a loop.

    Thanks,

    ren