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.

MSP430FR2522: Incorrect values from internal temperature sensor

Part Number: MSP430FR2522
Other Parts Discussed in Thread: MSP430FR2422

I am trying to read ambient temperature with an MSP430FR2522 using the internal temperature sensor.

I am using the calibration data (link) stored in the device to convert the ADC counts to temperature.

I see the output reacting to temperature changes, however the problem is that I seem to be getting values offset of about +57 °C with respect to the actual temperature.

Here is the gist of my code:

/* Minimalistic example code (not actual implementation) */

// Calibration values
#define ADC_TC_15V_30C  (*((uint16_t *) 0x1A1A)) // Temp sensor cal at 30 °C
#define ADC_TC_15V_85C  (*((uint16_t *) 0x1A1C)) // Temp sensor cal at 85 °C

// ADC initialization
PMMCTL0 = PMMPW; // Unlock PMM control register
PMMCTL2 |= TSENSOREN | INTREFEN; // Enable temperature sensor and internal VREF

ADCCTL0 &= ~ADCENC; // Disable ADC conversion before writing configuration

ADCCTL0 |= ADCSHT_8; // S&H time = 256 ADCCLK cycles
ADCCTL1 |= ADCSHP; // S&H source: ADCSC bit, S&H signal generated from timer, ADCCLK from MODCLK, single-channel mode
ADCCTL2 |= ADCPDIV__4 | ADCRES_1;   // 10-bit conversion results, ADCCLK = MODCLK/4, unsigned data, 200ksps
ADCMCTL0 |= ADCINCH_12 | ADCSREF_1; // Channel A12 (temp sensor), V(R+)=VREF=1.5V, V(R-)=AVSS

ADCIE |= ADCIE0; // Enable ADC interrupt

// Start ADC
ADCCTL0 &= ~ADCENC;
ADCCTL0 |= ADCON;
ADCCTL0 |= ADCENC | ADCSC;

// Temperature readout (inside ADC ISR)
ADCCTL0 &= ~ADCENC;
ADCCTL0 = ADCON_0;// Turn ADC off

uint16_t temperature;
temperature = 30 + ((ADCMEM0 - ADC_TC_15V_30C)*(85 - 30))/(ADC_TC_15V_85C - ADC_TC_15V_30C);

Am I correct in using the calibration values like this?


The datasheet states (link) that "The temperature sensor offset can vary significantly. TI recommends a single-point calibration to minimize the offset error of the built-in temperature sensor." but I don't understand if this is meant to be done in addition tothe calibration that is already provided.

Thank you for any help on the matter.

  • Hi liquidfluid

    Please check msp430fr2422_adc10_16.c on https://www.ti.com/tool/download/SLAC750

    I can see the The temperature calibration formula using CALADC_15V_30C and CALADC_15V_85C are same. 

    But please try this code example to check if the code example is OK.

    at the same time, please check ADC50 on MSP430FR2522 Device Erratasheet (Rev. H)

    I think your ADC conversion is not in LPM3. Please review this errata

    Thanks

  • Hi Xiaodong,
    Thank you for your reply.
    I tried to load the example code you mention to the MSP430FR2522 and that yields credible values for the room temperature.
    I will try to understand why with my configuration it doesn't work.
    Also thank you for pointing out the ADC50 bug on the errata sheet, that could become a problem in the application.

  • Did you look at the raw ADC data?

    If I saw something weird like this my first step would be to examine the input side. The ADC result and the calibration data from the TLV data structure.

    Well, the first step would be to validate the TLV data by verifying the checksum is valid before using it.

**Attention** This is a public forum