2019-03-24 09:58发布
qiushenghua 发表于 2015-7-28 10:34 内置温度传感器不同芯片参数略有差异。在info_A区域存在温度校准参数的。 电源不同正常情况下是不会影响AD ...
最多设置5个标签!
#include <msp430fr5949.h>
long temp;
float temperatureDegC;
float tt;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
REFCTL0=REFVSEL_0+REFON;
/* Initialize ADC12_A */
ADC12CTL0 &= ~ADC12ENC; // Disable ADC12
ADC12CTL0 = ADC12SHT0_0 + ADC12ON; // Set sample time
ADC12CTL1 = ADC12SHP; // Enable sample timer
ADC12CTL3 = +ADC12TCMAP; // Enable internal temperature sensor
ADC12MCTL0 |= ADC12VRSEL_1 + ADC12INCH_30; // ADC input ch A30 => temp sense
ADC12IER0 |= 0x001; // ADC_IFG upon conv result-ADCMEMO
while(!(REFCTL0 & REFGENRDY)); // Wait for reference generator
// to settle
ADC12CTL0 |= ADC12ENC;
_EINT();
while(1)
{
ADC12CTL0 |= ADC12SC; // Sampling and conversion start
__bis_SR_register(LPM0_bits + GIE); // LPM4 with interrupts enabled
__no_operation();
tt = (float)temp/4095*2500;
temperatureDegC =(tt-700)/25.0f;
__no_operation(); // SET BREAKPOINT HERE
}
}
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
{
temp = ADC12MEM0; // Move results, IFG is cleared
__bic_SR_register_on_exit(LPM4_bits); // Exit active CPU
}
一周热门 更多>