Quantcast
Channel: MSP low-power microcontrollers
Viewing all articles
Browse latest Browse all 62309

Forum Post: ADC conversion of sinewave facing distortion while increasing frequency

$
0
0
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 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); } }

Viewing all articles
Browse latest Browse all 62309

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>