EmbeddedRelated.com
Forums

Reading from multiple channels using ADC10 - DTC

Started by chaitanyakulkarni1984 May 5, 2011
Hi,

I am trying to read voltage values on two channels on eZ430-RF2500T.
Although I can successfully read from single channel, I am unable to do
so using two channels.

Here is my code:
int * readPtr = (int *)0x200; ADC10CTL1 = INCH_2 + CONSEQ_1; ADC10CTL0 REF2_5V + SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE; for
(countDown = 240; countDown > 0; countDown--); //delay to allow
references to settle ADC10AE0 |= 0x06; //110 ADC10DTC1 = 0x02;
// 2 conversions ADC10SA = 0x200; // Data buffer
start, same as readPtr above ADC10CTL0 |= ENC + ADC10SC; //Sampling and
conversion start while(!(ADC10CTL0 & ADC10IFG)); // wait till the block
conversion is complete ADC10CTL0 &= ~ADC10IFG; //reset ADC10IFG //code
for reading from readPtr
Please note that no interrupts are being used; results are read after
the ADC10IFG bit is set.

I am not getting ANY results with this code. The 'reading from readPtr'
part is never reached.

However, if I set ADC10DTC1 to 0x01, I can read from the highest
ordered pin. I.e. given that ADC10DTC1 is 0x01, I can read from A2 if
INCH_2 is selected, and from A1 if INCH_1 is selected.

I am unable to get conversions for both A2 and A1, though.

Any help for resolving this problem will be greatly appreciated.

Thanks!



Beginning Microcontrollers with the MSP430

I now have this working. This is the code that can read successfully from 4 pins simultaneously:

unsigned int res[5]; //for holding the conversion results
void main (void)
{

//code for connecting to AP

//reading voltage
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC10CTL1 = INCH_4 + CONSEQ_1; // A4/A3/A2/A1/A0, once multi channel
ADC10CTL0 = REF2_5V + ADC10SHT_2 + MSC+ REFON + ADC10ON + ADC10IE; //2.5 reference voltage
ADC10AE0 = 0x1F; // P2.0,1,2,3,4 ADC option select
ADC10DTC1 = 0x5; // 5 conversions
P1DIR |= 0x01; // Set P1.0 output

for (;;)
{
P1OUT |= 0x01; // Set P1.0 LED on
ADC10CTL0 &= ~ENC;
while (ADC10CTL1 & BUSY); // Wait if ADC10 core is active
ADC10SA = (int)res; // Data buffer start
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion ready
__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit
P1OUT &= ~0x01; // Clear P1.0 LED off
}

}

#pragma vectorC10_VECTOR
__interrupt void ADC10_ISR(void)
{
//code from reading from res and sending it to AP
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}

Thanks!

--- In m..., "chaitanyakulkarni1984" wrote:
> Hi,
>
> I am trying to read voltage values on two channels on eZ430-RF2500T.
> Although I can successfully read from single channel, I am unable to do
> so using two channels.
>
> Here is my code:
> int * readPtr = (int *)0x200; ADC10CTL1 = INCH_2 + CONSEQ_1; ADC10CTL0 > REF2_5V + SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE; for
> (countDown = 240; countDown > 0; countDown--); //delay to allow
> references to settle ADC10AE0 |= 0x06; //110 ADC10DTC1 = 0x02;
> // 2 conversions ADC10SA = 0x200; // Data buffer
> start, same as readPtr above ADC10CTL0 |= ENC + ADC10SC; //Sampling and
> conversion start while(!(ADC10CTL0 & ADC10IFG)); // wait till the block
> conversion is complete ADC10CTL0 &= ~ADC10IFG; //reset ADC10IFG //code
> for reading from readPtr
> Please note that no interrupts are being used; results are read after
> the ADC10IFG bit is set.
>
> I am not getting ANY results with this code. The 'reading from readPtr'
> part is never reached.
>
> However, if I set ADC10DTC1 to 0x01, I can read from the highest
> ordered pin. I.e. given that ADC10DTC1 is 0x01, I can read from A2 if
> INCH_2 is selected, and from A1 if INCH_1 is selected.
>
> I am unable to get conversions for both A2 and A1, though.
>
> Any help for resolving this problem will be greatly appreciated.
>
> Thanks!
>
>
>