I have read many posts on similar issues but couldn't figure out why I am not getting correct internal temperature readings.
ADC2_DEG() holds the temperature in 10's degree C. The temperature values I am getting makes no sense to real temperature readings.
/* special function reg*/
SFR_16BIT(ADC_GAINCAL);
SFR_16BIT(ADC_OFFSETCAL);
SFR_16BIT(ADC_2V5CAL);
SFR_16BIT(ADC_2V5T30CAL);
SFR_16BIT(ADC_2V5T85CAL);
#define ADC2_10DEG() ((uint16) (((ADC12MEM6-ADC_2V5T30CAL)*(850L-300L)/(ADC_2V5T85CAL-ADC_2V5T30CAL)+300L)))
/* init_adc routine */
void init_adc(void)
{
REFCTL0 &= ~REFMSTR;
ADC12CTL0 = ADC12SHT0_1 | ADC12SHT1_7 | ADC12ON | ADC12MSC | ADC12REF2_5V | ADC12REFON;
ADC12CTL1 = ADC12CSTARTADD_4 | ADC12SHP | ADC12SHS_3 | ADC12CONSEQ_1;
ADC12CTL2 = ADC12RES_2 | ADC12SR;
/* Conversion Memory Control Register
* Channels 4 - VBAT, 5 - VLOW, 6 - internal Temperature sensor
* Input channel select
*/
ADC12MCTL4 = ADC12SREF_1 | ADC12INCH_14; /* A14 = VSYS */
ADC12MCTL5 = ADC12SREF_1 | ADC12INCH_15; /* A15 = VLOW */
ADC12MCTL6 = ADC12SREF_1 | ADC12INCH_10; /* A10 = THERM */
ADC12MCTL6 |= ADC12EOS; /* End of sequence */
}
/* timer ISR */
__interrupt void TIMER0_B1_ISR(void)
{
if (TBIV & TB0IV_TB0IFG)
{
ADC12CTL0 &= ~ADC12ENC, ADC12CTL0 |= ADC12ENC; /* trigger ADC */
}
}
I got the following in my linker file:
ADC_GAINCAL = 0x1A16;
ADC_OFFSETCAL = 0x1A18;
ADC_2V5CAL = 0x1A20;
ADC_2V5T30CAL = 0x1A22;
ADC_2V5T85CAL = 0x1A24;
Any help is greatly appreciated!