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.