EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

ADC10 - MSP430F2274

Started by Ferdinando Terada June 24, 2008
Hey people...i'm having a trouble to do some sample conversations utilizing
the ADC10
I just took the code sample adc10_02.cpp from texas and substituted the:

ADC10AE0 |= 0x04; // P2.1 ADC option

to

ADC10AE0 |= 0x04; // P3.0 ADC option (A5)
is that all?

Beginning Microcontrollers with the MSP430

No, that's not all, you didn't do anything. You only changed the
comment which has no effect whatsoever on the generated code.
In case you miswrote and did change the channel, you still have to
change the configuration of the corresponding pin from digital I/O
(default at startup) to 'alternative' function, by means of PxSEL (in
your case BIT0 of P3SEL).

Michael K.

--- In m..., "Ferdinando Terada" wrote:
>
> Hey people...i'm having a trouble to do some sample conversations
utilizing
> the ADC10
> I just took the code sample adc10_02.cpp from texas and substituted the:
>
> ADC10AE0 |= 0x04; // P2.1 ADC option
>
> to
>
> ADC10AE0 |= 0x04; // P3.0 ADC option (A5)
> is that all?
>
>

ADC10AE0 |= 0x04; // P2.1 ADC option
and
ADC10AE0 |= 0x04;

How is that different ?

B rgds
Kris

-----Original Message-----
From: m... [mailto:m...] On Behalf Of Ferdinando Terada
Sent: Tuesday, 24 June 2008 11:38 PM
To: m...
Subject: [msp430] ADC10 - MSP430F2274

Hey people...i'm having a trouble to do some sample conversations utilizing
the ADC10
I just took the code sample adc10_02.cpp from texas and substituted the:

ADC10AE0 |= 0x04; // P2.1 ADC option

to

ADC10AE0 |= 0x04; // P3.0 ADC option (A5)
is that all?

hUAHUaHU Lol sorry microbit...uaeuea really sorry...i forgot to change..

ADC10AE0 |= 0x04; // P2.1 ADC option
and
ADC10AE0 |= 0x20; // P3.0 (A5)

Obs* in the code examples from texas i didn't see they using P2SEL=0x04 in
their example...is that necessary?
.

Obs* in the code examples from texas i didn't see they using P2SEL=0x02 in
their example...is that necessary?

When you connect an analog input to an I/O pin, you should set the
corresponding bit in the ADC10AE0/1 register. For example:

ADC10AE0 |= 0x04; // P2.2/A2 pin is an analog input
ADC10AE0 |= 0x20; // P3.1/A5 pin is an analog input

Doing so will disable both the digital output and digital input for
that pin. Thus the setting of the corresponding bit in PnSEL, PnDIR or
PnOUT does not matter.

In order to perform ADC to such an input, you have to program other
ADC10 registers to do so. In particular, the INCHx field of the
ADC10CTL1 has to be 0000 for A0, 0001 for A1, 0010 for A2, etc.

--- In m..., "Ferdinando Terada" wrote:
>
> hUAHUaHU Lol sorry microbit...uaeuea really sorry...i forgot to change..
>
> ADC10AE0 |= 0x04; // P2.1 ADC option
> and
> ADC10AE0 |= 0x20; // P3.0 (A5)
>
> Obs* in the code examples from texas i didn't see they using
P2SEL=0x04 in
> their example...is that necessary?
> .
>
>

thanks man..but i did that...here is my code..i changed some parts.. in the
lines where I wrote "I CHANGE HERE"

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC10CTL0 = ADC10SHT_2 + ADC10ON; // ADC10ON,
ADC10AE0 |= 0x20; // I CHANGED HERE - P3.0 ADC
option select (A5 correspond)
ADC10CTL1|= INCH_5; //I CHANGED HERE
P1DIR |= 0x01; // Set P1.0 to output direction
for (;;)
{
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
while(!ADC10CTL0&ADC10IFG) //I CHANGED HERE
if (ADC10MEM < 0x1FF)
P1OUT &= ~0x01; // Clear P1.0 LED off
else
P1OUT |= 0x01; // Set P1.0 LED on
}
}

What do you mean by: "while(!ADC10CTL0&ADC10IFG)"?

--- In m..., "Ferdinando Terada" wrote:
>
> thanks man..but i did that...here is my code..i changed some parts..
in the
> lines where I wrote "I CHANGE HERE"
>
> void main(void)
> {
> WDTCTL = WDTPW + WDTHOLD; // Stop WDT
> ADC10CTL0 = ADC10SHT_2 + ADC10ON; // ADC10ON,
> ADC10AE0 |= 0x20; // I CHANGED HERE - P3.0 ADC
> option select (A5 correspond)
> ADC10CTL1|= INCH_5; //I CHANGED HERE
> P1DIR |= 0x01; // Set P1.0 to output
direction
> for (;;)
> {
> ADC10CTL0 |= ENC + ADC10SC; // Sampling and
conversion start
> while(!ADC10CTL0&ADC10IFG) //I CHANGED HERE
> if (ADC10MEM < 0x1FF)
> P1OUT &= ~0x01; // Clear P1.0 LED off
> else
> P1OUT |= 0x01; // Set P1.0 LED on
> }
> }
>
>

Thanks mann....it worked...
well..that line you asked.....This bit "ADC10IFG" is set if ADC10MEM is
loaded with a conversion result, so if it not ended de conversion it
continues in that line....


The 2024 Embedded Online Conference