volatile long temp;
volatile long IntDegF;
volatile long IntDegC;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
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
__delay_cycles(37); // 35us delay to allow Ref to settle
// based on default DCO frequency.
// See Datasheet for typical settle
// time.
ADC12CTL0 |= ADC12ENC;
while(1)
{
ADC12CTL0 |= ADC12SC; // Sampling and conversion start
__bis_SR_register(LPM4_bits + GIE); // LPM0 with interrupts enabled
__no_operation();
// Temperature in Celsius
// ((A10/4096*1500mV) - 894mV)*(1/3.66mV) = (A10/4096*410) - 244
// = (A10 - 2438) * (410 / 4096)
IntDegC = ((temp - 2438) * 410) / 4096;
// Temperature in Fahrenheit
// ((A10/4096*1500mV) - 829mV)*(1/2.033mV) = (A10/4096*738) - 408
// = (A10 - 2264) * (738 / 4096)
IntDegF = ((temp - 2264) * 738) / 4096;
__no_operation(); // SET BREAKPOINT HERE
}
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(ADC12_VECTOR))) ADC12ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(ADC12IV,34))
{
case 0: break; // Vector 0: No interrupt
case 2: break; // Vector 2: ADC overflow
case 4: break; // Vector 4: ADC timing overflow
case 6: // Vector 6: ADC12IFG0
temp = ADC12MEM0; // Move results, IFG is cleared
__bic_SR_register_on_exit(LPM4_bits); // Exit active CPU
break;
case 8: break; // Vector 8: ADC12IFG1
case 10: break; // Vector 10: ADC12IFG2
case 12: break; // Vector 12: ADC12IFG3
case 14: break; // Vector 14: ADC12IFG4
case 16: break; // Vector 16: ADC12IFG5
case 18: break; // Vector 18: ADC12IFG6
case 20: break; // Vector 20: ADC12IFG7
case 22: break; // Vector 22: ADC12IFG8
case 24: break; // Vector 24: ADC12IFG9
case 26: break; // Vector 26: ADC12IFG10
case 28: break; // Vector 28: ADC12IFG11
case 30: break; // Vector 30: ADC12IFG12
case 32: break; // Vector 32: ADC12IFG13
case 34: break; // Vector 34: ADC12IFG14
default: break;
}
}
请问:
// Temperature in Celsius
1. // ((A10/4096*1500mV) - 894mV)*(1/3.66mV) = (A10/4096*410) - 244 此处的894mv和3.66mv是什么含义?以及后面的410和244
// Temperature in Fahrenheit
2.// ((A10/4096*1500mV) - 829mV)*(1/2.033mV) = (A10/4096*738) - 408 同理,此处的829mv和2.033mv是表示什么,等号右边的738和408是什么意思
【MSP430趣谈】MSP430第十二讲之ADC(下)
你看看这个帖子,里面有讲温度的计算公式的
谢谢,温度公式的得出似乎不是由用户手册里 N = 4095 ×( Vin -Vr_)/(VR+ - Vr_) 得出