我用600HZ去采电压,和用4KHZ去采,采样值能差个2%。不管我把
ADC12CTL0 = ADC12SHT0_1这个采样保持的时间设置多长以及系统低功耗还是去掉ADC12PWRMD,结果都不变?
再问一个问题
1.我现在用的是多通道采样,没用重复的多通道采样。因为我发现用了重复的多通道采样后(并去掉ADC12MSC)。
TA0CCR0 = 7; //4; //7; // TA0 4K 采样频率
TA0CCR1 = 3;
本是4KHZ的,结果只有800HZ。为啥?
void adcRestart (void)
{
//Turn OFF ADC12B Module & Clear Interrupt Registers
ADC12CTL0 &= ~ADC12ENC;
ADC12CTL0 &= ~(ADC12ON + ADC12SC);
__delay_cycles (10);
ADC12IER0 &= 0x0000; //Reset ALL interrupt enables
ADC12IER1 &= 0x0000;
ADC12IER2 &= 0x0000;
ADC12IFGR0 &= 0x0000; //Reset ALL interrupt flags
ADC12IFGR1 &= 0x0000;
ADC12IFGR2 &= 0x0000;
ADC12CTL0 = ADC12SHT0_1 | ADC12ON | ADC12MSC;
/*用了ADC12OSC(ADC12内部时钟源)分频为1 */
ADC12CTL1 = ADC12SHP | ADC12SHS_1 | ADC12_B_SEQOFCHANNELS; // Use sampling timer 序列通道单次转换
ADC12CTL2 |= ADC12RES_2 | ADC12PWRMD; // 12-bit conversion results //低功耗
#if ADC_INNER_REF2_5 == 1
/*内部参考 */
// Channel2 ADC input select; Vref=VREF buffered
ADC12MCTL0 = ADC12VRSEL_1 | ADC12INCH_2;
ADC12MCTL1 = ADC12VRSEL_1 | ADC12INCH_12;
ADC12MCTL2 = ADC12VRSEL_1 | ADC12INCH_15;
ADC12MCTL3 = ADC12VRSEL_1 | ADC12INCH_13;
ADC12MCTL4 = ADC12VRSEL_1 | ADC12INCH_14 | ADC12EOS;
#else
/*外部参考 */
// Channel2 ADC input select; Vref=VREF buffered
ADC12MCTL0 = ADC12VRSEL_14 | ADC12INCH_2;
ADC12MCTL1 = ADC12VRSEL_14 | ADC12INCH_12;
ADC12MCTL2 = ADC12VRSEL_14 | ADC12INCH_15;
ADC12MCTL3 = ADC12VRSEL_14 | ADC12INCH_13;
ADC12MCTL4 = ADC12VRSEL_14 | ADC12INCH_14 | ADC12EOS;
#endif
ADC12IER0 = ADC12IE4;
ADC12IER2 = ADC12TOVIE | ADC12OVIE;
if (SYSTEM_WORK_MODE_HIGH_ADC == g_systemWorkMode)
{
TA0CCR0 = 7; //4; //7; // TA0 4K 采样频率
TA0CCR1 = 3;
}
else
{
TA0CCR0 = 54; //600HZ
TA0CCR1 = 50;
}
TA0CCTL1 |= OUTMOD_2; // TBCCR0 toggle (ON period = ~230us)
ADC12CTL0 |= ADC12ENC; //开始转
TA0CTL = TASSEL__ACLK | MC__UP | TACLR; // ACLK, up mode
}
灰小子:
关于第一个问题,首先要确认下是否真的是4k频率采样,还是后面说的800Hz。采样数据有差异有可能是外部电路的阻抗匹配问题。
maya maya:
回复 灰小子:
所说的频率都是真的,都用示波器量过。TI有没有4KHZ多通道 重复采样的配置例子?
我直接把电池的电源分压进ADC脚,这阻抗匹配还能有啥问题。
感觉MSP430的ADC不是太好用,问题多多