求解MSP430的程序,关于G2553的AD转换程序,为什么下面的程序不能循环采样电压呢?
#include"msp430.h"unsignedlonginfor=0x000;voidADC10Init(){P1SEL|=BIT0;ADC10CTL0&=~ENC...
#include "msp430.h"
unsigned long infor=0x000;
void ADC10Init()
{
P1SEL|= BIT0;
ADC10CTL0 &= ~ENC;
ADC10CTL0|=REFON+ADC10ON+SREF_1+ENC+REF2_5V+ADC10IE+ ADC10SHT_0+ADC10SC+MSC;
ADC10CTL1|=CONSEQ_0+INCH_0+SHS_1+ADC10DIV_3;
ADC10AE0|= 0x01;
_EINT();
}
#pragma vector = ADC10_VECTOR
__interrupt void ADC10_Interrupt(void)
{
infor=ADC10MEM;
if (infor<0x200)
{P1OUT|=BIT6;}
else
{P1OUT&=0x6F;}
ADC10IFG==0x00;
}
void main( void )
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR=0xff;
P1OUT=0x00;
ADC10Init();
while(1)
{
ADC10CTL0|=ENC+ADC10SC;
}
} 展开
unsigned long infor=0x000;
void ADC10Init()
{
P1SEL|= BIT0;
ADC10CTL0 &= ~ENC;
ADC10CTL0|=REFON+ADC10ON+SREF_1+ENC+REF2_5V+ADC10IE+ ADC10SHT_0+ADC10SC+MSC;
ADC10CTL1|=CONSEQ_0+INCH_0+SHS_1+ADC10DIV_3;
ADC10AE0|= 0x01;
_EINT();
}
#pragma vector = ADC10_VECTOR
__interrupt void ADC10_Interrupt(void)
{
infor=ADC10MEM;
if (infor<0x200)
{P1OUT|=BIT6;}
else
{P1OUT&=0x6F;}
ADC10IFG==0x00;
}
void main( void )
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR=0xff;
P1OUT=0x00;
ADC10Init();
while(1)
{
ADC10CTL0|=ENC+ADC10SC;
}
} 展开
2个回答
展开全部
0.5v的没找到,我这有个0.25的,别问我,我也忘了
#include <msp430x14x.h>
#include "BoardConfig.h" //板上控制文件
void main(void)
{
WDTCTL = WDTHOLD + WDTPW; // 关看门狗
BoardConfig(0xb0); //开流水灯,关数码管和电平转换
CACTL1 = CARSEL + CAREF0 + CAON ; // Vcc/4 = - cmp
CACTL2 = P2CA0; // 使用 CA0
P2DIR = 0xff;
P2OUT = 0xff;
while(1)
{
if((CACTL2 | 0xfe) ==0xff)
{ // 比较电压是否超过0.25Vcc
P2OUT &= ~BIT4;
CACTL1 &= 0xfe; // CAIFG = 0
}
else
{
P2OUT |= BIT4;
}
}
}
#include <msp430x14x.h>
#include "BoardConfig.h" //板上控制文件
void main(void)
{
WDTCTL = WDTHOLD + WDTPW; // 关看门狗
BoardConfig(0xb0); //开流水灯,关数码管和电平转换
CACTL1 = CARSEL + CAREF0 + CAON ; // Vcc/4 = - cmp
CACTL2 = P2CA0; // 使用 CA0
P2DIR = 0xff;
P2OUT = 0xff;
while(1)
{
if((CACTL2 | 0xfe) ==0xff)
{ // 比较电压是否超过0.25Vcc
P2OUT &= ~BIT4;
CACTL1 &= 0xfe; // CAIFG = 0
}
else
{
P2OUT |= BIT4;
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询