#include < msp430f5529.h>
#define NUM_OF_RESULT 8;
volatile unsigned int results[NUM_OF_RESULT]; //开辟8个16位内存空间
void main(void)
{
WDTCL = WDTPW + WDTHOLD;
P6SEL |=BIT0;
ADC12CTL0 = ADC12ON + ADC12SHT0_8 + ADC12MSC; //打开adc12,设置采样间隔,设置多次采样转换
ADC12CTL1 = ADC12SHP + ADC12CONSEQ_2; //设置采样定时器作为采样触发信号,采样模式为单通道多次转化
ADC12IE = BIT0;
ADC12CTL0 |= ADC12ENC; //使能转换
ADC12CTL0 |= ADC12SC; //启动转换
__bits_SR_register(LPM4_bits + GIE);
}
#progma vector = ADC12_VECTOR;
__interrupt void ADC12ISR (void)
{
static unsigned char index = 0;
switch(__even_in_range(ADC12IV,34))
{
case 0: break;
case 2: break;
case 4: break;
case 6:
result[index] = ADC12MEM0; //读取转换结果
index++;
if(index==8)
{
index = 0;
}
case 8: break;
case 10: break;
default: break;
}
好分享,谢谢