本帖最后由 gaochy1126 于 2012-6-11 16:04 编辑
数据可以通过查看寄存器得到!
#include <msp430g2231.h>
volatile long tempRaw;存放ADC转换数值的
void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW + WDTHOLD; 停用看门狗
if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
while(1); 启动ADO为MCLK
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
BCSCTL3 |= LFXT1S_2;
IFG1 &= ~OFIFG;
BCSCTL2 |= SELM_0 + DIVM_3; 使用DCO八分频
while(1)
{
ADC10CTL1 = INCH_10 + ADC10DIV_0; 选择通道
ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON; 开启REF和ADC10
_delay_cycles(5); 等待参考设置
ADC10CTL0 |= ENC + ADC10SC; 启动转换
_delay_cycles(100); 等待转换
ADC10CTL0 &= ~ENC; 停止ADc转换
ADC10CTL0 &= ~(REFON + ADC10ON);
tempRaw = ADC10MEM; 、
_delay_cycles(125000);
}
} |