想利用P1.0P1.1输入两直流,序列通道多次测量求电压值,为什么输出错误啊。。。。求大神帮助
#include "msp430.h"
unsigned int a[32],b,i,j;
float v[2];
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P1OUT=0;
P1SEL|=0X03;
//P1DIR&=~(0X03);
ADC10CTL0 = MSC+ REFON + ADC10ON+REF2_5V;
ADC10CTL1 |=INCH_1+CONSEQ_3;
ADC10DTC1 |=0X20;
ADC10AE0 |=0X03;
while(1)
{
ADC10CTL0&=~(ENC+ADC10SC);
ADC10CTL0 |= ADC10SC+ENC;
ADC10SA=(unsigned int)a;
for(i=0;i<2;i++)
{
b=0;
for(j=0;j<16;j++)
{
b+=a[i+j*2];
}
}
for(i=0;i<2;i++)
{
b=b/16;
v
=b*2500/1023;
}
}
}
此帖出自小平头技术问答
2 while(1)
{
ADC10CTL0&=~(ENC+ADC10SC);
ADC10CTL0 |= ADC10SC+ENC;
ADC10SA=(unsigned int)a;
for(i=0;i<2;i++)
{
b=0;
for(j=0;j<16;j++)
{
b+=a[i+j*2];
}
}
for(i=0;i<2;i++)
{
b=b/16;
v=b*2500/1023;
}
一周热门 更多>