EmbeddedRelated.com
Forums

Regarding ADC10MEM

Started by "paddu.koti" April 20, 2008
Hi,

I am using ADC10 in msp430f1232 and I have set analog input as pin 20
(A4) as shown in the program.When using A0 as the analog input I am
getting the right output,but if I use A4(pin20), I am not able to
get the correct values in ADC10MEM register,the LED starts blinking
even if there is no analog input in A4 and the ADC10MEM register
value shows more than 0x1FF.
Can anyone please help me out to solve this problem.

Below is the sample program where I have changed ADC option as A4
//*******************************************************************
#include

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10IE; // ADC10ON,interruptEN
ADC10AE |= 0x10; // P2.4 ADC option A4
P2DIR |= 0x20; // Set P1.0 to output
for (;;)
{
ADC10CTL0 |= ENC + ADC10SC; // Sampling and
_BIS_SR(CPUOFF + GIE); // LPM0, ADC10_ISR will
if (ADC10MEM < 0x1FF)
P2OUT = 0x00; // Clear P2.5 LED off
else
P2OUT = 0x20; // Set P2.5 LED on
}
}

// ADC10 interrupt service routine
__interrupt void ADC_ISR (void);
ADC10_ISR(ADC_ISR)
__interrupt void ADC_ISR (void)
{
_BIC_SR_IRQ(CPUOFF); // Clear CPUOFF bit
}
//*******************************************************************

Thankyou..

Beginning Microcontrollers with the MSP430

Hi,
You got the right output at A0 since the default is INCH_0. Try to insert in your code INCH_4 before enabling the sampling. This will select which channel to be sampled (INCH_1 for A1, INCH_2 for A2 and so on...). I'm not sure what control register (I think ADC10CTL1? so for ex. ADC10CTL1 = INCH_4 for your case) sets this parameter, please check the user guide. Hope this would help.

----- Original Message ----
From: paddu.koti
To: m...
Sent: Sunday, April 20, 2008 11:11:12 AM
Subject: [msp430] Regarding ADC10MEM
Hi,

I am using ADC10 in msp430f1232 and I have set analog input as pin 20
(A4) as shown in the program.When using A0 as the analog input I am
getting the right output,but if I use A4(pin20), I am not able to
get the correct values in ADC10MEM register,the LED starts blinking
even if there is no analog input in A4 and the ADC10MEM register
value shows more than 0x1FF.
Can anyone please help me out to solve this problem.

Below is the sample program where I have changed ADC option as A4
//********** ********* ********* ********* ********* ********* ********* ***
#include

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10IE; // ADC10ON,interruptEN
ADC10AE |= 0x10; // P2.4 ADC option A4
P2DIR |= 0x20; // Set P1.0 to output
for (;;)
{
ADC10CTL0 |= ENC + ADC10SC; // Sampling and
_BIS_SR(CPUOFF + GIE); // LPM0, ADC10_ISR will
if (ADC10MEM < 0x1FF)
P2OUT = 0x00; // Clear P2.5 LED off
else
P2OUT = 0x20; // Set P2.5 LED on
}
}

// ADC10 interrupt service routine
__interrupt void ADC_ISR (void);
ADC10_ISR(ADC_ ISR)
__interrupt void ADC_ISR (void)
{
_BIC_SR_IRQ( CPUOFF); // Clear CPUOFF bit
}
//********** ********* ********* ********* ********* ********* ********* ***

Thankyou..

____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ