2019-03-24 09:58发布
qiushenghua 发表于 2015-7-28 10:34 内置温度传感器不同芯片参数略有差异。在info_A区域存在温度校准参数的。 电源不同正常情况下是不会影响AD ...
541873558 发表于 2015-7-28 10:45 #include long temp; float temperatureDegC; float tt; int main(void) { WDTCTL = WDTPW + ...
最多设置5个标签!
4095的话相当于就是采样口的电压跟参考电压一样了
电源不同正常情况下是不会影响ADC采样的,除非你配置的参考电压不对。建议贴出ADC初始化部分的代码,更容易看出原因来。
#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
}
这个是不接外部电源能正常采样的程序
一周热门 更多>