折腾了一晚上,终于实现了,程序可能还有不足,欢迎批评指正!
#include "msp430x22x4.h"
int *s1=(int*)0x0200;
int *s2=(int*)0x0202;
int *ad1=0,*ad2=0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P4DIR|=BIT0+BIT1;
P4OUT|=BIT0;
P4OUT&=~BIT1;
ADC10CTL1 = INCH_1 + CONSEQ_1; // A2/A1/A0, single sequence
ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE;
ADC10DTC1 = 0x02; // 3 conversions
ADC10AE0 |= BIT0+BIT1; // P2.2,1,0 ADC10 option select
__bis_SR_register(GIE); // LPM0, ADC10_ISR will force exit
while(1)
{
ADC10CTL0 &= ~ENC;
while (ADC10CTL1 & BUSY); // Wait if ADC10 core is active
ADC10SA = 0x200; // Data buffer start
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
}
}
// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
ad1=s1;
ad2=s2;
} |