我正在使用MSP430F5438A和MSP-FET430UIFdebugger。我运行一个简单的代码来测量ADC采样所需的时间。代码很简单,如下所示。问题是当我调试相同的代码时,当我观察TA1R寄存器,它给出0X2D(即十进制45),因此转换时间为45 /(8MHZ),这给出了5.6微秒。但是不使用调试器,当我在LCD中输出相同的TA1R值时,它给出了十进制的175是22微秒。为什么它不同?我在采样完成后立即停止计时器然后在LCD中显示值。这是代码..(我只使用SCLK发布了code.im的逻辑)< / p>
static bool flag=0;
static uint8 temp=0;
main()
{
ADC12CTL0 = ADC12SHT02 + ADC12ON; // Sampling time, ADC12 on
ADC12CTL1 = ADC12SHP; // Use sampling timer
ADC12IE |=BIT0; // Enable interrupt
ADC12CTL0 |= ADC12ENC;
P6SEL |= BIT0; // P6.0 ADC option select
updateLcd();
TA1CCTL0 = CCIE;
TA1CCR0 = 65535;
TA1CTL = TASSEL_2 + MC_2 + TACLR;//continous mode,SMCLK
ADC12CTL0|= ADC12SC;
while(flag==0);
TA1CTL=MC_0;//Halt the timer
updateLcd();
}
#pragma vector = ADC12_VECTOR
__interrupt void ADC12_ISR(void)
{
switch(__even_in_range(ADC12IV,34))
{
case 0: break; // Vector 0: No interrupt
case 2: break; // Vector 2: ADC overflow
case 4: break; // Vector 4: ADC timing overflow
case 6: // Vector 6: ADC12IFG0
temp=ADC12MEM0;
flag=1;
break;
case 8: break; // Vector 8: ADC12IFG1
case 10: break; // Vector 10: ADC12IFG2
case 12:break; // Vector 12: ADC12IFG3
case 14: break; // Vector 14: ADC12IFG4
case 16: break; // Vector 16: ADC12IFG5
case 18: break; // Vector 18: ADC12IFG6
case 20: break; // Vector 20: ADC12IFG7
case 22: break; // Vector 22: ADC12IFG8
case 24: break; // Vector 24: ADC12IFG9
case 26: break; // Vector 26: ADC12IFG10
case 28: break; // Vector 28: ADC12IFG11
case 30: break; // Vector 30: ADC12IFG12
case 32: break; // Vector 32: ADC12IFG13
case 34: break; // Vector 34: ADC12IFG14
default: break;
}
}
static void updateLcd(void) {
lcdBufferClear(0);
lcdBufferPrintString(0, "Timer Test", 0, eLcdPage0);
lcdBufferSetHLine(0, 0, LCD_COLS-1, 7);
lcdBufferPrintString(0, "Timer value:", 0, eLcdPage3);
lcdBufferPrintInt(0,temp ,70, eLcdPage4);
lcdBufferPrintInt(0,TA1R,30,eLcdPage5);
lcdSendBuffer(0);
}