能不能帮我看看,我设置采集电压大于参考电压(即2.5v)的一半就亮,可是小灯不论电压多少都不亮,不知道问题出在哪。。
#include <msp430x14x.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
int i;
P6DIR |= BIT2;P6OUT |= BIT2;
ADC12CTL0 = SHT0_2 + ADC12ON+REFON+REF2_5V;
ADC12CTL1 = SHP;
ADC12MCTL0=SREF_1;
ADC12IE = 0x01;
for(i=0;i<0x3600;i++)
{
}
ADC12CTL0 |= ENC;
P6SEL |= 0x01;
P2DIR |= BIT4;
for (;;)
{
ADC12CTL0 |= ADC12SC;
_BIS_SR(CPUOFF + GIE);
}
}
// ADC12 interrupt service routine
#pragma vector=ADC_VECTOR
__interrupt void ADC12_ISR (void)
{
if (ADC12MEM0 < 0x7FF)
P2OUT &= ~BIT4;
else
P2OUT |= BIT4;
_BIC_SR_IRQ(CPUOFF);
}
|