Forums

eZ430-2500RF ADC sampling multiple channels

Started by cvrider June 24, 2008
I am trying to create code to continuously make a single sample of a
couple ADC channels and send it over an RF link to the access point.
I am working off the sample that comes with the eZ430-2500RF dev
kit. I would like to sample A0 and A1. However, my code seems to
capture the same value for both A0 and A1 as if it is not correctly
sampling A1. My code is here:

ADC10CTL0 = ADC10SHT_3 + ADC10ON + ADC10IE; // ADC10ON, interrupt
enabled
ADC10AE0 |= 0x01; // P2.0 ADC option select

ADC10CTL0 |= ENC + ADC10SC; // Sampling and
conversion start
__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will
force exit
ADC10CTL0 &= ~ENC;

adc[0] = ADC10MEM;
msg[0] = adc[0]&0xFF;
msg[1] = (adc[0]>>8)&0xFF;

ADC10CTL0 = ADC10SHT_3 + ADC10ON + ADC10IE; // ADC10ON,
interrupt enabled
ADC10AE0 |= 0x04; // P2.1 ADC option
select

ADC10CTL0 |= ENC + ADC10SC; // Sampling and
conversion start
__bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will
force exit

ADC10CTL0 &= ~ENC;

ADC10CTL0 &= ~(REFON + ADC10ON); // turn off A/D to save
power

adc[1] = ADC10MEM;
msg[2] = adc[1]&0xFF;
msg[3] = (adc[1]>>8)&0xFF;

>From what I have read, I would think I need to use ADC10CTL1 and set
INCH to the proper channel. However, I never set this for A0 and it
seems to sample correctly. I just cannot sample any other channels.
What am I doing wrong? Is there a better way to do this?

Thanks,
Mark

Beginning Microcontrollers with the MSP430

You did not change ADC10CTL1 (part of that register, INCHx, selects
the channel), thus it retains its Power-On-Reset value of ox0000.
This means channel 0 is selected.

--- In m..., "cvrider" wrote:
>
> I am trying to create code to continuously make a single sample of a
> couple ADC channels and send it over an RF link to the access point.
> I am working off the sample that comes with the eZ430-2500RF dev
> kit. I would like to sample A0 and A1. However, my code seems to
> capture the same value for both A0 and A1 as if it is not correctly
> sampling A1. My code is here:
>
> ADC10CTL0 = ADC10SHT_3 + ADC10ON + ADC10IE; // ADC10ON, interrupt
> enabled
> ADC10AE0 |= 0x01; // P2.0 ADC option select
>
> ADC10CTL0 |= ENC + ADC10SC; // Sampling and
> conversion start
> __bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will
> force exit
> ADC10CTL0 &= ~ENC;
>
> adc[0] = ADC10MEM;
> msg[0] = adc[0]&0xFF;
> msg[1] = (adc[0]>>8)&0xFF;
>
>
> ADC10CTL0 = ADC10SHT_3 + ADC10ON + ADC10IE; // ADC10ON,
> interrupt enabled
> ADC10AE0 |= 0x04; // P2.1 ADC option
> select
>
> ADC10CTL0 |= ENC + ADC10SC; // Sampling and
> conversion start
> __bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will
> force exit
>
> ADC10CTL0 &= ~ENC;
>
> ADC10CTL0 &= ~(REFON + ADC10ON); // turn off A/D to save
> power
>
> adc[1] = ADC10MEM;
> msg[2] = adc[1]&0xFF;
> msg[3] = (adc[1]>>8)&0xFF;
>
> From what I have read, I would think I need to use ADC10CTL1 and set
> INCH to the proper channel. However, I never set this for A0 and it
> seems to sample correctly. I just cannot sample any other channels.
> What am I doing wrong? Is there a better way to do this?
>
> Thanks,
> Mark
>