This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADC conversion of sinewave facing distortion while increasing frequency

Other Parts Discussed in Thread: MSP430G2553

Dear All

I am facing a problem in ADC Conversion of MSP430G2553 Launch pad.

I am getting ADC conversion of 100mHz sine wave exactly. But when I increase the frequency from 100mHz to higher frequencies, I got some values as output. But when I plot a graph using these values, the sine wave shown is a distorted version of sine wave. Please help me to resolve this issue.The code I wrote is pasted below:

#include <msp430g2553.h>
volatile long voltageRaw;
int adc[200] = {0};
int i=0;    int kl;
void main(void)
{
    WDTCTL = WDTPW + WDTHOLD;

    BCSCTL1 = CALBC1_1MHZ;   // Set range as we did in the last lab
    DCOCTL = CALDCO_1MHZ;    // Set DCO step + modulation (same as last lab)

    BCSCTL3 |= LFXT1S_2;                 // LFXT1 = VLO, so VLO will source ACLK
    IFG1 &= ~OFIFG;                      // Clear OSCFault flag
    BCSCTL2 |= SELM_0 + DIVM_3 + DIVS_3;          // MCLK sourced from DCO, MCLK = DCO/8, SMCLK = DCO/8
    ADC10CTL0 &= ~ENC;
   //ADC10CTL1 = INCH_4 + ADC10SSEL_3 + ADC10DIV_4 + CONSEQ_2;
    //ADC10CTL0 = ADC10ON + ADC10SHT_3 + MSC +  SREF_0 + REFON ;
   ADC10CTL0 = ADC10ON | ADC10SR | ADC10SHT_3 | SREF_0 | REFON | MSC;
   ADC10CTL1 = CONSEQ_2 | ADC10SSEL_3 | ADC10DIV_2 | SHS_0 | INCH_4;
    ADC10AE0 |=  BIT4; // Set P1.4 and P1.5 as ADC inputs
     _delay_cycles(20);
     ADC10CTL0 |= ENC + ADC10SC;
    //     while(1)
    //     {


     //           __delay_cycles(1000);

   //             ADC10CTL0 |= ENC + ADC10SC;

    //        while (ADC10CTL1 & BUSY);

     //           kl = ADC10MEM;

            //   P2OUT |=(char)(kl/100);

    //     }
while(1)
{

//    _delay_cycles(1000);
    //ADC10MEM=ADC10MEM;

    //ADC10CTL0 &= ~ENC;
    //ADC10CTL0 &= ~(REFON + ADC10ON);
    //ADC10CTL0 |= ENC + ADC10SC;
     // while (ADC10CTL1 & BUSY);
    voltageRaw = ADC10MEM;
    adc[i]=voltageRaw;
    i++;

//     _delay_cycles(125000);
}
}

  • You are continuously reading ADC data register - conversion is finished or not. Also your code have buffer overrun error which most probably will cause crash. I would suggest to study ADC sample code first - to familiarize with ADC use, how to wait for conversion done. And don't show us your trash code, clean it before showing

**Attention** This is a public forum