#define Num_of_Results 9
/* Arrays to store SD24 conversion results */
unsigned long Ch0results[Num_of_Results];
unsigned long Ch1results[Num_of_Results];
unsigned long Ch2results[Num_of_Results];
unsigned long Ch0results2[Num_of_Results];
unsigned long Ch1results2[Num_of_Results];
unsigned long Ch2results2[Num_of_Results];
unsigned long Ch0results3[Num_of_Results];
unsigned long Ch1results3[Num_of_Results];
unsigned long Ch2results3[Num_of_Results];
void main(void)
{
volatile unsigned int i; // Use volatile to prevent removal
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1SEL |= BIT0; // Set SMCLK at P1.0
P1SEL2 |= BIT0; // Set SMCLK at P1.0
P1DIR |= BIT0+BIT3; // P1.1 and P1.0 = output direction
//BCSCTL1 |= XT2OFF; //默认关闭XT2
//BCSCTL2 |= SELS+SELM_3; //SMLK=VLOCLK MCLK = VLO
BCSCTL3 |= LFXT1S_2; // LFXT1 = VLOCLK BCSCTL2 |= SELM_3; //MCLK = VLO
SD24CTL = SD24REFON + SD24SSEL_2 + SD24XDIV_3; // 1.2V ref, SMCLK
SD24CCTL0 |= SD24GRP+SD24UNI +SD24LSBTOG + SD24OSR_1024; // Group with CH1
SD24INCTL0 |= SD24GAIN_2;
SD24CCTL1 |= SD24GRP+SD24DF + SD24OSR_1024; // Group with CH2
SD24CCTL2 |= SD24IE+SD24DF + SD24OSR_1024; // Enable interrupt
for (i = 0; i < 0x3600; i++); // Delay for 1.2V ref startup
SD24CCTL2 |= SD24SC; // Set bit to start conversion
__bis_SR_register(GIE); // Enter LPM0 w/ interrupts
while(1);
}
#pragma vector=SD24_VECTOR
__interrupt void SD24AISR(void)
{
// static unsigned int index = 0;
switch (SD24IV)
{
case 2: // SD24MEM Overflow
break;
case 4: // SD24MEM0 IFG
break;
case 6: // SD24MEM1 IFG
break;
case 8: // SD24MEM2 IFG
Ch0results[0] = SD24MEM0;
Ch0results[1] = SD24MEM0; Ch0results[2]=Ch0results[0]<<13;
Ch0results[3]=Ch0results[1]&&0x003fff;
Ch0results[4]=Ch0results[0]+Ch0results[1];
Ch0results[5]=Ch0results[4]>>5;
P1OUT ^=BIT3;
break;
}
}
gandong:
没人回应啊,难怪这个官方论坛很冷清啊
Nathan Zaker:
回复 gandong:
1、是指以信号频率的1024倍采样?
2、预制是否指的是PRELoad寄存器?
3、数据“飘”的影响因素比较多,特别是在高精度的测量中,这里使用的24位精度已经非常高,抛开代码,可能是供电引起的也可能是本身目标采样信号在变化。
gandong:
回复 Nathan Zaker:
程序里采样数据是16位,怎么计算得到24位
HUIJUN YUAN:
回复 Bruce Wei:
我也碰到这个问题,我觉得TI这个AD做得不好,电路问题一般不会波动超过10MV,设置问题大些,感觉TI的技术支持比以前慢了好多