请问谁用过MSP430F2013 SD16,我把相关的寄存器都配置了,但是转换还是不准,而且随着输入电压增大,感觉误差越大,请各位帮我看看,谢谢了
oid int_clk()
{
BCSCTL1 &= ~XTS; //打开LFXT1并处于低频模式
BCSCTL1 = RSEL0 + RSEL1 + RSEL2;//标称频率 RSELx = 7
DCOCTL = DCO0 + DCO1; //内部DCOx = 3 频率在(2.2 V/3 V) 0.80-1.50MHz之间
DCOCTL = MOD0 + MOD1; //调整频率
//(默认)MCLK时钟源为DCOCLK,SMCLK时钟源为DCOCLK
do
{
IFG1 &= ~OFIFG; //清除振荡错误标志
for(i = 0; i < 100; i++)
_NOP(); //延时等待
}
while ((IFG1 & OFIFG) != 0); //如果标志为1继续循环等待
IFG1 &= ~OFIFG;
}
//==============================================================================
//
void int_adc()
{
P1SEL |= 0X03; // 选择P1.0&P1.1第二功能
SD16AE |= SD16AE1 + SD16AE0; // SD16 External Input Enable P1.0&P1.1
SD16CTL = SD16REFON+SD16SSEL_1; // 1.2V ref, SMCLK
// SD16CTL &= ~SD16VMIDON + ~SD16LP; // SD16 Switch Vmid Buffer off and not Low Power Mode Enable
SD16CCTL0 |= SD16SNGL + SD16IE + SD16UNI + SD16OSR_256; // Single conv, enable interrupt,Unipolar(1) Mode,Channel x OverSampling Ratio 256
SD16INCTL0 |= SD16INTDLY_0 + SD16INCH_0 + SD16GAIN_1; // SD16 Interrupt after 4.Conversion,SD16 Input Channel select A0 ,Input Pre-Amplifier Gain Select *1
for (i = 0; i < 0x3600; i++); // Delay for 1.2V ref startup
} |