#include <msp430x14x.h>
static unsigned int results;
void main(void)
{
volatile unsigned int i;//unsigned long int j;
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P6SEL |= 0x01; // Enable A/D channel A0
ADC12CTL0 = ADC12ON+SHT0_2+REFON+REF2_5V; // Turn on and set up ADC12
ADC12CTL1 = SHP+CONSEQ_0; // Use sampling timer
ADC12MCTL0 = SREF_1; // Vr+=Vref+
P4DIR=0X01; ADC12IE = 0x01;
for ( i=0; i<0x3600; i++) // Delay for reference start-up
{
}
_EINT();
ADC12CTL0 |= ENC; // Enable conversions
while (1)
{
ADC12CTL0 |= ADC12SC;
}
}
#pragma vector=ADC_VECTOR
__interrupt void ADC12ISR (void)
{
results = ADC12MEM0;
if(results<=0x7ff)
P4OUT=0X01;
else P4OUT=0X00;
//_BIC_SR_IRQ(LPM0_bits); // Clear LPM0, SET BREAKPOINT HERE
}
此帖出自
小平头技术问答
一周热门 更多>