#include<msp430g2553.h>
unsigned int a[3];
unsigned int i=0;
void main(void) {
WDTCTL=WDTPW+WDTHOLD;
P1OUT=0;
ADC10CTL0|=ADC10ON+ADC10IE+REFON+REF2_5V+SREF_1+MSC;
ADC10CTL1|=INCH_2+CONSEQ_3;
ADC10DTC1|=0X01;
ADC10AE0|=0X07;
P1DIR=BIT0+BIT6;
while(1)
{
ADC10CTL0&=~ENC;
while(ADC10CTL1&ADC10BUSY);
ADC10CTL0|=ADC10SC+ENC;
ADC10SA=(unsigned int )a+i;
__bis_SR_register(LPM0_bits+GIE);
if(a
>1)
P1OUT^=BIT0;
else
P1OUT^=BIT6;
i++;
if(i>3)
i=0;
}
}
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
LPM0_EXIT;
}
我想用序列通道重复转换模式来转换3个通道的模拟量,可是每次i++后用于储存的数组后移了,但是ADC10SC的地址值却没有跟着移位,如何做到让每i++一次,通道也向后移一位?
此帖出自小平头技术问答
一周热门 更多>