我用adc12来检测。现在8个口都用到了。请问怎么从8个通道采值。
#include <msp430x24x.h>
unsigned int da_v[8],v;
void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P6SEL |= 0xff; // Enable A/D channel A0
ADC12CTL0 = ADC12ON+SHT0_2+REFON+REF2_5V; // Turn on and set up ADC12
ADC12CTL1 = SHP; // Use sampling timer
ADC12MCTL0 = SREF_1 + INCH_0; // Vr+=Vref+
for ( i=0; i<0x3600; i++); // Delay for reference start-up
ADC12CTL0 |= ENC; // Enable conversions
while (1)
{
ADC12CTL0 |= ADC12SC; // Start conversion
while ((ADC12IFG & BIT0)==0);
da_v[0] = ADC12MEM0;
ADC12IFG &= ~BIT0;
ADC12MEM0 = 0;
v = da_v[0];
// ADC12MCTL0 = SREF_1 + INCH_1;
ADC12CTL1 |= CSTARTADD_1; // ?为什么ADC12CTL1的高4位改变不了?????
ADC12CTL0 |= ADC12SC; // Start conversion
while ((ADC12IFG & BIT1)==0);
da_v[1] = ADC12MEM1;
ADC12MEM0 = 0;
v = da_v[1];
_NOP(); // SET BREAKPOINT HERE
}
}
请问:为什么ADC12CTL1的高4位改变不了?
怎么切换到下一个通道去采集?谢谢!
此帖出自
小平头技术问答
一周热门 更多>