Other Parts Discussed in Thread: MSP430F2274
Hi,
I have some questions regarding about the ADC10 usage of MSP430f2274.
1)
In my case, I have 3 analog inputs I need to process continuously. Apparently, the analog inputs converted by the microcontroller do not behave as expected.
The following code is placed inside a while loop. Is this the correct way to process 3 different inputs? Is this known as the 'Single-Channel Single-Conversion Mode'? Or should I use 'Sequence-of-Channel Mode' to handle it?
ADC10CTL1 = INCH_0; // A0
ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE + REF2_5V;
for(temp = 10; temp > 0; temp-- ); // delay to allow reference to settle
ADC10CTL0 |= ENC + ADC10SC; // Start to perform sampling and conversion
for(temp = 10; temp > 0; temp-- ); // delay to allow reference to settle
value1= ADC10MEM;
ADC10CTL0 &= ~ENC;
ADC10CTL1 = INCH_1; // A1
ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE + REF2_5V;
for(temp = 50; temp > 0; temp-- ); // delay to allow reference to settle
ADC10CTL0 |= ENC + ADC10SC; // Start to perform sampling and conversion
for(temp = 50; temp > 0; temp-- ); // delay to allow reference to settle
value2 = ADC10MEM;
ADC10CTL0 &= ~ENC;
ADC10CTL1 = INCH_2; // A2
ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE + REF2_5V;
for(temp = 10; temp > 0; temp-- ); // delay to allow reference to settle
ADC10CTL0 |= ENC + ADC10SC; // Start to perform sampling and conversion
for(temp = 10; temp > 0; temp-- ); // delay to allow reference to settle
value3 = ADC10MEM;
ADC10CTL0 &= ~ENC;
2)
Is it necessary to use the DTC to transfer conversion results from ADC10MEM? As you can see, I am using value1, value2 and value3 to transfer from ADC10MEM.
3)
Is it necessary to use following line of code while handling ADC10? I am only using A0, A1 and A2 for the inputs.
ADC10AE0 |= 0x07;
When I leave this line of code out, apparently, ADC can still be performed providing that I give:
P2DIR = 0x00;
P2OUT = 0x00;
P2SEL |= 0x00;
From what I understand, ADC10AE0 |= 0x07; should be coded and P2DIR and P2SEL are 'don't care' when handling ADC10.
4)
Can someone explain what are the operators |= and &= ?
Any help is appreciated! I am stuck at this for a week already.
Thanks!