#include "msp430x44x.h" // Standard Equations
#define Num_of_Results 11
static unsigned int results[Num_of_Results]; // Needs to be global in this
// example. Otherwise, the
// compiler removes it because it
// is not used for anything.
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P6SEL |= 0x01; // Ena××e A/D channel A0
ADC12CTL0 = ADC12ON+SHT0_8+MSC ; // Turn on ADC12, set sampling time
ADC12CTL1 = SHP+CONSEQ_2; // Use sampling timer, set mode
ADC12IE = 0x01; // Ena××e ADC12IFG.0
ADC12CTL0 |= ENC; // Ena××e conversions
_EINT(); // Ena××e interrupts
ADC12CTL0 |= ADC12SC; // Start conversion
_BIS_SR(LPM0_bits); // Enter LPM0
}
interrupt[ADC_VECTOR] void ADC12ISR (void)
{
static unsigned int index = 0;
results[index] = ADC12MEM0; // Move results
index = (index+1)%Num_of_Results; // Increment results index, modulo
}
试一下这个,再在中断里加一个判断,当index为11时就关毕ADC_VECTOR中断,则在results[0]---results[9]中存的数据就是10次的转换的结果。