ADC channels readings

Below is my sample code, through which I am reading voltages on four ADC channels, but in all cases I am getting the same voltage levels on all channels, that is one channel reading on the other channels.

Initiation :

ADC10CTL1 = SHS_0 + CONSEQ_1;

ADC10CTL0 = SREF_0 + ADC10SHT_0 + REFON + ADC10ON + ENC ;

ADC10DTC1=0x01;

conversion Code:

int Adc_Conv( int channel ) {

ADC10CTL1 = channel;

ADC10CTL0 |= ENC + ADC10SC;

while( ADC10CTL1 & ADC10BUSY );

ADC10CTL0 &= ~ENC;

return ADC10MEM;

}

If I read from the ADC Channels:

Temp1= Adc_Conv( 0x0400 );

Temp2= Adc_Conv( 0x1400 );

Temp3= Adc_Conv( 0x2400 );

Temp4= Adc_Conv( 0x3400 );

for the first time , that is for Temp1 this code works fine but for the rest all it is not doing conversion so please, if any can help me out where i have to make change inorder to do all channels readings thanks in advance. regards Boni

Reply to
manohar2008
Loading thread data ...

Why would you expect any sensible answer when you haven't said which processor you are programming?

Mark Borgerson

Reply to
Mark Borgerson

Which text adventure game was it that responded to the "help" keyword with "How should I know, try tap dancing"? Was it The Pawn (Magnetic Scrolls)?

Reply to
larwe

(reformatted)

Presumably, this is C (or a dialect thereof). Presumably, these are manifest constants (?) Yet, you are *assigning* values to them... :<

I *think* you intended this (preceding) statement to store the value of "channel" into a control register whose address is specified by "ADC10CTL1". But, I suspect you have just updated a *variable* called ADC10CTL1 which may not be connected to the hardware to which you *think* it is connected. Hard to say as you haven't indicated what each of these symbols/variables mean. :< (i.e., if ADC10CTL1 isn't a pointer...)

Again, it seems like you are expecting this to return the value of a hardware (I/O) register "ADC10MEM". But, it is just returning the contents of a variable that you have (probably not even initialized!).

Including a code snippet without everything pertinent is a pretty silly way to get help :<

"The answer I got is '5'. Why is that?"

"Um, what was the *question* you asked and the answer that you expected??"

Have you verified that the answer you are getting (even though you think it is WRONG) actually bears some correlation with reality? I.e., if you vary the voltage impressed on ALL of the A/DC input pins, do you see *any* change in the result?? Does the change that you observe correlate with the voltage that you have impressed? (i.e., does the value move up when the voltage moves up?) Or, is it just totally random (suggesting that your code is just returning uninitialized values from memory...)

Please be a bit more considerate of people's time in the future and ask questions that don't require lots of work on *our* part to save *you* the time preparing better questions. :-/

Reply to
D Yuniskis

Mark Borgerson schrieb:

It's a MSP430.

cheers Gunther

Reply to
Gunther Mannigel

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.