SanShark 发表于 2012-7-9 15:36:00

求教:MSP430F5438和5438A内部测温二极管是否相同?

如题
同样的代码,用在5438上可以测温,用在5438A上无法测温,请高手指点
源代码为TI官方例程:

//******************************************************************************
//MSP430F54x Demo - ADC12, Sample A10 Temp and Convert to oC and oF
//
//Description: A single sample is made on A10 with reference to internal
//1.5V Vref. Software sets ADC12SC to start sample and conversion - ADC12SC
//automatically cleared at EOC. ADC12 internal oscillator times sample
//and conversion. In Mainloop MSP430 waits in LPM4 to save power until
//ADC10 conversion complete, ADC12_ISR will force exit from any LPMx in
//Mainloop on reti.
//ACLK = n/a, MCLK = SMCLK = default DCO ~ 1.045MHz, ADC12CLK = ADC12OSC
//
//Uncalibrated temperature measured from device to devive will vary do to
//slope and offset variance from device to device - please see datasheet.
//
//                MSP430F5438
//             -----------------
//         /|\|            XIN|-
//          | |               |
//          --|RST          XOUT|-
//            |               |
//            |A10            |
//
//   W. Goh
//   Texas Instruments Inc.
//   November 2008
//   Built with CCE Version: 3.2.2 and IAR Embedded Workbench Version: 4.11B
//******************************************************************************
#include "msp430x54x.h"

volatile long temp;
volatile long IntDegF;
volatile long IntDegC;

void 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
}
}

#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
{
switch(__even_in_range(ADC12IV,34))
{
case0: break;                           // Vector0:No interrupt
case2: break;                           // Vector2:ADC overflow
case4: break;                           // Vector4:ADC timing overflow
case6:                                  // Vector6:ADC12IFG0
    temp = ADC12MEM0;                     // Move results, IFG is cleared
    __bic_SR_register_on_exit(LPM4_bits);   // Exit active CPU
    break;
case8: break;                           // Vector8: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;
}
}

Monklong 发表于 2012-7-10 15:21:07

你有没有MSP430F5438A的BSL下载软件呀,有的话传我一份呀,谢谢!1181014519@qq.com 邮箱地址

HadesHe 发表于 2012-7-10 17:19:01

骚年,里面ADC12的TLV变了 REF也不是当年那个REF了

SanShark 发表于 2012-7-10 19:01:56

恕我愚钝,请明言。
还有:我也观察过ADC12MEM0的值,始终在0左右徘徊。

HadesHe 发表于 2012-7-11 08:51:20

TLV STRUCT里面存着一些校正信息你的ADC12会用到 比如零点 增益 以及 参考 还有温度 这些都与你的ADC12通道10采集温度有关.
页: [1]
查看完整版本: 求教:MSP430F5438和5438A内部测温二极管是否相同?