1

im using MSP430F5438A with MSP-FET430UIFdebugger.Im running a simple code for measuring the time it takes for a ADC Sample.The code is simple as posted below.The problem is when i debug the same code and when i observe the TA1R register,it gives 0X2D(i.e 45 in decimal),so the conversion time is 45/(8MHZ) which gives 5.6 micro seconds.But instead of using the debugger and when i output the same TA1R value in LCD it gives 175 in decimal which is 22 micro seconds.Why is it different?i stop the timer as soon as sampling is done and then im displaying the value in LCD.This is the code..(i have posted only the logic of code.im using SCLK)

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);
}
erathina
  • 53
  • 1
  • 7
  • Can you please re-post this question on **Embedded System** SE site. This is more hardware / firmware specific question. – prasad Aug 10 '15 at 16:19

0 Answers0