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.

MSP430F5438 on-chip temperature sensor

Hi,

I am trying to use the on-chip temperature sensor to sense the temperature value. Then, adjust the LCD contrast (my LCD screen is close to CPU).

So, in order to find the offset value of the on-chip sensor, I have already tried a single-point calibration, and my method is described as follows:

(1)  Get the temperature  value from on-chip sensor under the room temperature.

(2) Put a thermal couple on the surface of the CPU and meausre the temperature with a very accurate device.

(3) Then, compare two values, and find the difference between them, which is the offset for the on-chip tmepreature sensor.

 

However, after I add the offset to the equation, the result from the on-chip sensor and the value read from my reference thermal couple device are not same, when the temperature is changed.

For example, if I heat the CPU for a little while, the values from the on-chip sensor and  my reference thermal couple are 35C and 31C respectively. However, after the temperature drops back to the room temperature, they are same again.

So, I don't know what I missed here. Any help will be great!

 

Thanks!

 

Liu

  • Please note the specs for the temperature sensor, figure 17 and Note 2 on page 62 of the datasheet. Essentially the temperature sensor can require a 1-point calibration to get a semi-accurate value, since the temp sensor can be as much as 20 degrees off initially (mentioned in Note 2).

    In my experience performing a 1-point calibration at 25 deg C shows accuracy at that temperature to be very good (as you've seen). Now, as you move away from 25 deg calibration point then accuracy can diminish proportionally with the TCsensor (mV/degC) min and max stated in the datasheet (figure 17).

  • Hi Brandon,

    I don't really understand TCsensor(mV/degC). Could you please give me an example?

    In the beginning, I thought if I got an offset under the room temperature,  I could use it over the entire temperature range because from the figure 17 on page 62 (datasheet), the curve of temperature vs voltage is pretty linear. There is no slope adjustment required.

    However, from your explanations above, did you mean the offset would vary along with the temperature?

    For example, offset at 25 deg C is x, but it could change to y at 30 deg C.

     

    Thanks for you help!

     

    Liu


  • Essentially there are two main errors for the temp sensor: offset and gain.

    If you look in the datasheet, it has a footnote that says the offset can be as much as +/-20 degC, and that a single point calibration is recommended to eliminate this.  After the offset error, you've got the sensor output change per degC (this is TCsensor).  The datasheet shows TCsensor=3.66 mV/degC nominal.  This is basically a gain error.  This varies from device to device.  If you took a second calibration point (in addition to the point for offset error calibration), you could calibrate this gain error out too and have very accurate results.

    I hope that helps!

  • I don't know how you guys can manage to read temperature sensor off 5438A.  I can not read any voltage.

    I am using external 2.5V REF.  I am selecting channel 10, as lited in family's guide..but voltage read is just few bits.  The funny thing is that all other channels read OK, including channel 11 (AVCC-GND/)2

    I have tried all sort of reference selection, all sorts of sampling delay.. but no use.  This is true on two diffrent chips

    I thought diode temperature sensor does not work on 5438A, until I saw this thread

    What am I doing wrong?

  • I have the same issue as Visualfortran w/the 5438A chip: The termp sensor does not appear to work, w/the ADC randomly showing only very small values [0, 1, 2, 3] when ADCMCTLx.ADC12SREFx=0x1.  When ADCMCTLx.ADC12SREFx=0x0, I consistently read zero.  Turning on/off ADC12REFON does not appear to have any effect.

    So, does the on-chip temp sensor work in the 54xx family?

    Here's the source:

     /* P6 & P7 GPIO/ADC pins enabled in main.c */
        /* - CTL0: turn on ADC12, extend sampling time to avoid overflow of results
         * - CTL1: use sampling timer, repeat seq, div ADC12 clk / 8
         * - CTL2: prediv ADC12 clk / 4, 12-bit res */
        ADC12CTL0   = ADC12ON | ADC12MSC | ADC12SHT1_12 | ADC12SHT0_12 | ADC12REFON;
        ADC12CTL1   = ADC12SHP | ADC12CONSEQ_3 | ADC12DIV_7;
        ADC12CTL2   = ADC12PDIV | ADC12RES_2;
        ADC12MCTL0  = ADC12INCH_0;              // ref+=AVcc, channel = An
        ADC12MCTL1  = ADC12INCH_1;              // ref+=AVcc, channel = An
        ADC12MCTL2  = ADC12INCH_2;              // ref+=AVcc, channel = An
        ADC12MCTL3  = ADC12INCH_3;              // ref+=AVcc, channel = An
        ADC12MCTL4  = ADC12INCH_4;              // ref+=AVcc, channel = An
        ADC12MCTL5  = ADC12INCH_5;              // ref+=AVcc, channel = An
        ADC12MCTL6  = ADC12INCH_6;              // ref+=AVcc, channel = An
        ADC12MCTL7  = ADC12INCH_7;              // ref+=AVcc, channel = An
        ADC12MCTL8  = ADC12INCH_12;             // ref+=AVcc, channel = An
        ADC12MCTL9  = ADC12INCH_13;             // ref+=AVcc, channel = An
        ADC12MCTL10 = ADC12INCH_14;             // ref+=AVcc, channel = An
        ADC12MCTL11 = ADC12INCH_10 | ADC12SREF_1 | ADC12EOS;  // ref+=Vref, channel = temp,end seq

    regards,

    gifford scott

  • With regards to the issue of the temp sensor on the '5438A not functioning, please refer to TI's response in the post @ http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/t/31641.aspx.

    The issue stems from the fact that the '5438A has the REF (voltage reference) module implemented, whereas the '5438 (non-A part) does not.

    To enable the on-chip temp sensor w/minimal changes to the '5438A, turn on the REF module w/the following line of code:

        REFCTL0 = REFON;

    This REF module setting will turn on the REF module, allowing voltage to be applied to the temp sensor diode.  By clearing the REFMSTR bit in REFCTL0, the ADC module controls the REF module, using the appropriate legacy control bits w/in the ADC registers.

    Hope this helps.

    regards,

    gifford scott

    DST

  • Thanks Scott,

    You put me in the right direction, but there is one major problem with the documentation on 54xxA series.

    According to data sheet  "MPS430F5437A", on page-62: 

    Vtemp = 0.00366 (TEMP in C) + 0.894  <-- does not work

    According to the example given in http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/t/31641.aspx:

    Vtemp = 0.00225 (TEMP in C) + 0.680  <-- works

    And yes you are right, REFON must be set, or it will not work. 

    I am taking 16 averages with SAMPLE_7, and it is jumping around by 4C (reading 26-30C).  My actual temperature is 27C.  So far I have only tested one board

  • Visual,

    Thanks for the feedback.  The default temp algorithm in the MSP430F54xx datasheet is way off base - presumably it works better for the non-A devices, but who knows?  Glad to hear you found a better algorithm.  In any case, if you want decent accuracy, you should access the TLV temp reference values stored in flash, as recommended in the user guide.  The A sample devices have bogus TLV temp values, but using the non-A parts from our reference boards, I've gotten very good results.  Happy bug hunting.

    gifford scott

    DST

  • So if a 1-point calibration is performed for the MSP430F543x internal temperature sensor, what kind of accuracy in degrees C can we expect?  And what about for a 2-point calibration?  Can someone please share their experiences?

  • When rewriting my code library from 1611 to 5438 (non-A), I also discovered the temperature sensor being anything but reliable.

    I tried to get any usable temperature value from it using the datasheet values and a single-pont calibration. Even without it, I'd expect, using the given formula and datasheet values, that despite of the absolute (offset) error, a change in 1 degree temperature should result in a change of 1 degree in computed/measured temperature. But far from that, I got practically everything.

    So when almost at the point of giving-up, I discovered a completely different method: The use of the calibration data stored in the TLV structure of every device.

    It holds a 30 and 85 degree conversion reading of the temp sensor for 1.5 and 2.5V internal source.

    With these 4 values, it is possible to do a 2-point calibration for both internal references (note that if you select an external reference for the TEMP channel, these values are void). The documentation of the 5438 (and any other decomentation I found where the term 'TLV' is mentioned) is very 'thin' when it comes to explaining what the entries actually mean. With some educated guessing you can extract some information from it, while other is completely opaque.

    To my surprise, it seemed to almost instantly work. No offset voltage, no mV/deegree, just two pairs of values that directly match an ADC reading and a temperature. And the result was what I expected, though I didn't actually do a exact verification of the result, just using an ice cube for 0 degree and room temperature (plus cpu heating) as the second check. It looked fairly well and good enough for my applications.

    Here is the calculation formula for offset and factor, as well as the calculation for the actual value in degree Celsius

      tFactor = (((550UL)<<12)+150)
                /(
                    (*((unsigned int *)(0x1a1e + ((_SYSTEM_AD_REF & 1)?6:0))))
                   -(*((unsigned int *)(0x1a1c + ((_SYSTEM_AD_REF & 1)?6:0))))
                  ); // 550 is ref temp diff (1/10°), +150 is added for cheap rounding (calibration points are ~300 apart)
      tOffset = ((unsigned long)(*((unsigned int *)(0x1a1c +((_SYSTEM_AD_REF & 1)?6:0))))*tFactor)-(300UL<<12);

    _SYSTEM_AD_REF is 1 for 2.5V and 0 for 1.5V. The two addresses are the storage locations of the reference values in the TLV structure of the 5438.

    The formula looks a bit complex but this is to enhance precisition (therefore the shift by 12 bit) and eliminate the need of any division when calculationg the temperature from the ADC reading. Divisions are SLOOOOOW. But since the above calculations are only done once at startup...

    The actual calculation for the temperature is

    tempC=((((long)ADC12MEM[tempchannel]*tFactor)-tOffset)>>12);

    tempC is the (signed) temperature in 0.1 degree Celsius steps.

    If anyone want to try it and do a more sophisticated test of relative and absolute precision, please tell me the result.

     

**Attention** This is a public forum