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.

F6638 Internal temp sensor read is radically incorrect

I'm getting some radically incorrect-seeming values from the internal temp sensor on the ADC on my MSP430.  I copied and pasted code from the example fiile msp430f66xx_adc_10.c:

		ADC12_A_clearInterrupt(ADC_BASE,ADC12IFG0);
		 REFCTL0 &= ~REFMSTR;                      // Reset REFMSTR to hand over control to
		                                            // ADC12_A ref control registers
		  ADC12CTL0 = ADC12SHT0_8 + ADC12REFON + ADC12ON;
		                                            // Internal ref = 1.5V
		  ADC12CTL1 = ADC12SHP;                     // enable sample timer
		  ADC12MCTL0 = ADC12SREF_1 + ADC12INCH_10;  // ADC i/p ch A10 = temp sense i/p
		  // ADC12IE = 0x001;                          // ADC_IFG upon conv result-ADCMEMO
		  for(nTimeout=0;nTimeout<30;nTimeout++)                         // Delay to allow Ref to settle
		    ADC12CTL0 |= ADC12ENC;

		    ADC12CTL0 &= ~ADC12SC;
		    ADC12CTL0 |= ADC12SC;                   // Sampling and conversion start

		    while( !(ADC12_A_getInterruptStatus(ADC_BASE,ADC12IFG0)) );

		    nTimeout = ADC12MEM0;

		    // Temperature in Celsius
		    // ((A10/4096*1500mV) - 680mV)*(1/2.25mV) = (A10/4096*666) - 302
		    // = (A10 - 1858) * (666 / 4096)
		    nTimeout = ((nTimeout - 1858) * 666) / 4096;

		    // Temperature in Fahrenheit
		    // Tf = (9/5)*Tc + 32
		    nTimeout = ((nTimeout - 1858) * 1199) / 4096 + 32;

..I'm getting values in ADC12MEM0 upwards of 2150 (decimal), whici converts into a pretty weird temperature considering the ambient in here is about 73f.

Is there anything blantantly wrong here?  I assumed that a sample would work (all the otrhers I've looked at have).

All info appreciated!

Ed Averill

 

  • Hmm.. readng the TLV on this device at 0x1a1a, for the 1.5V 30C calibration, I'm seeing 2250 decimal.

    Is it possible that the chip is actually running close to 85F?

  • What is nTimeout? Hopefully a long? (else your intermediate results in the formula will be truncated to 16 bit, which will give wrong results).
    The temperature sensor has a large offset range and also a large gain range. The users guide values are just an average value. The demo code unfortunately uses this average value rather than the device-specific values.
    The TLV structure of the 5x/6x family devices (see the ‘device descriptors’ section in the datasheet) holds calibration values for 30°C and 85°C (for 1.5, 2.0 and 2.5V reference), which were actually measured values on this specific MSP at production time. With these two points, you can calculate offset and gain of your specific sensor. Don’t bother calculating the voltage in mV.
    (CAL_85-CAL_30)/55 is the gain (counts per °C) and CAL_30 is the offset. (The header files define symbols for these values, separate for 1.5, 2.0 and 2.5V reference – check the header files for the actual symbol names)

    Don’t forget that the measured temperature is the internal die temperature, which is (slightly or significantly) above ambient temperature (depending on power dissipation)

  • nTimeout is a long timeout counter, but this isn't timing out (whew).

    After examining the calibration values (thanks for that info!) it appears the reading is actually sane, I use the calibration values to compute temperature and things are within a "sensible" range.

    Thanks for the help, have a great weekend!

    Ed Averill

     

**Attention** This is a public forum