TI中文支持网
TI专业的中文技术问题搜集分享网站

msp430FR6972 adc重启动延时问题

我发现一个问题,ADC初始化后,软件时因为要同步采样,所以得清除timer重启。但是本来应该200us就能进入重启动后的第一个中断,但是有时会delay 250us,所以450us才能进入,把timer和adc都折腾了两天(),还是这样。请高手指点一下。

void adcEnterHighMode (void)
{

   if ((ADC_STATE_LOW == g_adcState) || (ADC_STATE_STOP == g_adcState))
   {

//最开始初始化一次
      g_adcState = ADC_STATE_HIGH;
//Turn OFF ADC12B Module & Clear Interrupt Registers
ADC12CTL0 &= ~ADC12ENC;
while (ADC12CTL1 & ADC12BUSY);
ADC12CTL0 &= ~(ADC12ON + ADC12SC);

__no_operation ();
__no_operation ();
ADC12IER0 &= 0x0000; //Reset ALL interrupt enables
ADC12IER1 &= 0x0000;
ADC12IER2 &= 0x0000;
ADC12IFGR0 &= 0x0000; //Reset ALL interrupt flags
ADC12IFGR1 &= 0x0000;
ADC12IFGR2 &= 0x0000;

//周期是250us
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 //低功耗

/*外部参考 */
// Channel2 ADC input select; Vref=VREF buffered

ADC12MCTL0 = ADC12VRSEL_14 | ADC12INCH_15;
ADC12MCTL1 = ADC12VRSEL_14 | ADC12INCH_12;
ADC12MCTL2 = ADC12VRSEL_14 | ADC12INCH_2;
ADC12MCTL3 = ADC12VRSEL_14 | ADC12INCH_13; //电压
ADC12MCTL4 = ADC12VRSEL_14 | ADC12INCH_14 | ADC12EOS; //电流

ADC12IER0 = ADC12IE4;
//ADC12IER2 = ADC12TOVIE | ADC12OVIE;

TA0CCR0 = 7;

TA0CCR1 = 6;

TA0CCTL1 |= OUTMOD_2; // TBCCR0 toggle (ON period = ~230us)

ADC12CTL0 |= ADC12ENC; //开始转
TA0CTL = TASSEL__ACLK | MC__UP | TACLR; // ACLK, up mode

}
else
{

//20秒调下面一次,正常是200us左右进第一次ADC12IE4中断,但有时要加250us,刚有是一次采样时间,得450us左右进一次,这就有同步的误差
TA0CTL = TASSEL__ACLK | MC__STOP | TACLR;
TA0CTL |= TAIFG;
ADC12CTL0 &= ~ADC12ENC;
while (ADC12CTL1 & ADC12BUSY);

__no_operation ();
__no_operation ();
ADC12IER0 = 0x0000; //Reset ALL interrupt enables
ADC12IER1 = 0x0000;
ADC12IER2 = 0x0000;
ADC12IFGR0 = 0x0000; //Reset ALL interrupt flags
ADC12IFGR1 = 0x0000;
ADC12IFGR2 = 0x0000;

TA0CCR0 = 7;

TA0CCR1 = 6;

TA0CCTL1 |= OUTMOD_2; // TBCCR0 toggle (ON period = ~230us)
TA0CTL = TASSEL__ACLK | MC__UP | TACLR;
ADC12IER0 = ADC12IE4;
ADC12CTL0 |= ADC12ENC;

}

}

请高手指点一下,谢谢!

maya maya:

有TI的员工吗?请帮个忙。指点下,项目就卡在这了。三个同采同步要求高,一下差250us不及格。

我查了,在发生250us的delay时, ADC12TOVIE和 ADC12OVIE中断没发现过。

反正就是timer清除计数,就有问题。是不是cpu有这个bug?若有,如何避规

再次感谢

灰小子:

没看懂楼主的意图。是要准确定时间隔采样吗?

可以在定时器中断里使能adc采样的,不知道这样能否满足楼主的需求?

maya maya:

回复 灰小子:

都已经用定时器作的,但要定时清除定时器,会丢adc中断

赞(0)
未经允许不得转载:TI中文支持网 » msp430FR6972 adc重启动延时问题
分享到: 更多 (0)