|
#include "msp430G2553.h"
long temp;
long intDegF;
long intDegC;
//***************初始化ADC****/
void ADC10_init(void)
{
ADC10CTL0 &=~ENC; //关闭转换
ADC10CTL0 =ADC10IE + ADC10ON + REFON + ADC10SHT_3 + REF2_5V;
// ADC10IE 使能ADC转换中断,即开启
// ADC10ON 使能ADC转换
// REFON 打开内部参考电压开关
// DC10SHT_3 时钟及64倍频选择 0-4倍 1-8倍;2-16倍,3-64被
// SREF_1 参考电压选择,选内部可用REF2_5V ,内部2.5V ;REF1_5V ,内部1.5V
ADC10CTL1 =CONSEQ_0 + ADC10SSEL_0 + ADC10DIV_3 + SHS_0 + INCH_10;
// CONSEQ_0 ===0单通道转换;1多通道伦流 2复合
// ADC10SSEL_1 时钟选择 0-ADC10OSC;1-ACLK;2-MCLK;3-SMCLK
// ADC10DIV_3 ADC时钟
// SHS_0 ADC控制选择
//INCH_10 模拟信号输入通道选择
__delay_cycles(30000);
ADC10CTL0 |= ENC; //开启转换
}
//************主函数***************************
void main()
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC10_init();
while(1)
{
ADC10CTL0 |=ENC +ADC10SC;
LPM0; //__bis_SR_register(CPUOFF + GIE);
temp =ADC10MEM; //Read Data
intDegC =((temp-673)*423)/1024;
__no_operation();
}
}
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_A(void)
{
__bic_SR_register_on_exit(LPM4_bits);
}
|
|