Hi,
I am reading two analog pin P1.4 and P1.7 on MSP430g2553. I am using ADC10 single channel single conversation mode in CCS compiler.The problem is I am reading AN4 pin then ı am reading AN7. when I try to read AN7 first I have to set ADC10CTL1=INCH_7 but ıt doesnt allow change it because first have to clear ADC10CTL0 ENC bit.
But I couldnt clear ENC bit.
while(1)
{
ADC10CTL0&=0xFD; // try to clear ENC
ADC10CTL1=INCH_4; // P1.4 AN4 ENABLE
ADC10AE0 = BIT4; // P1.4 AN4 ENABLE
ADC10CTL0=ADC10SHT_2 + ADC10ON + ENC + ADC10SC;
ADCValue=ADC10MEM;
ADC10CTL0&=0xFD; // try to clear ENC
ADC10CTL1=INCH_7; // P1.7 AN7 ENABLE
ADC10AE0 = BIT7; // P1.7 AN7 ENABLE
ADC10CTL0=ADC10SHT_2 + ADC10ON + ENC + ADC10SC;
ADCValue=ADC10MEM;
}
On the other hand sequence of channels mode ı am getting wrong values.
unsigned int res[2]; //for holding the conversion results
void main (void) {
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC10CTL1 = INCH_7 + CONSEQ_1; // A7 once multi channel
ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON;
ADC10AE0 = 0x90; // P1.4,7 ADC option select
ADC10DTC1 = 0x02; // 2 conversions
for (;;) {
ADC10CTL0 &= ~ENC;
while (ADC10CTL1 & BUSY); // Wait if ADC10 core is active
ADC10SA = (int)res; // Data buffer start
ADC10CTL0 |= ENC + ADC10SC;
}
}
When I using ADC10 single channel single conversation mode I can read AN7 and AN4 separately and correctly. But When I use both of them single mode I cant clear ENC bit. This is the firs problem.
When I use sequence of channels mode ı cant getting both values correctly or repeatedly adresses.
Can you tell me what are the problems?
Thank you.