我想实现用定时器隔段时间进行ad10多通道采样,想用中断嵌套实现,可是只能一次采集,还有好像进不了adc10的中断,是中断优先级的问题,但如何修改可以达到目的,求助

#include "msp430g2553.h" #define num_of_results 12

#define uint unsigned int

#define uchar unsigned char

//unsigned int a[50],b[50];

//static float adc0,adc1;

int cc=0;

unsigned char flag;

void led_init();

void timer_init(); void delay(int);

void ADC_convert();

uint a[num_of_results];

void delay(int i)

{int j,k;

for(j=0;j<110;j++) for(k=0;k<i;k++); }

void led_init()

{ P1DIR|=(1<<6); //P1.6为LED }

//--------------------------

void timer_init()

{ TACCR0 =62500; //计到62500,约500ms

TACTL = TASSEL_2+ID_3+MC_1+TACLR; //设置TIMERA的时钟源为SMCLK(1M),8分频后(125K),计数模式为up,到CCR0再自动从0开始计数

TACCTL0 |= CCIE; // CCR0 interrupt enabled }

//--------定时器中断函数------------

#pragma vector=TIMER0_A0_VECTOR __interrupt void Timer_A(void)

{ //TACCTL0&=~ CCIE; //关中断 _EINT();

cc+=1; if(cc==2) //1s=1000ms=2*500 定时

{ P1OUT^=(1<<6); //P1.6 LED取反

cc=0;

ADC_convert(); } }

//*************ADC转化及中断程序*********************

void ADC_convert()

{//static unsigned int results[num_of_results] = {0}; // static unsigned char index ;//静态变量

_BIS_SR(GIE); ADC10CTL1 = INCH_5 + CONSEQ_1; // A3/A2/A1, single sequence

ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE + REFON + REF2_5V ;

ADC10DTC1 = 0x0c; // 3 conversions

ADC10AE0 |= 0x38; // P1.3,2,1 ADC10 option select

P1DIR |= 0x01; // Set P1.0 output

_EINT();

ADC10CTL0 &= ~ENC;

while (ADC10CTL1 & BUSY); // Wait if ADC10 core is active // ADC10SA = 0x200; // Data buffer start

// for(index=0;index<12;index+=6)

{ ADC10SA = (uint)a;//[index++] ; //(uint)a }

P1OUT |= 0x01; // P1.0 = 1 // delay(2500);

ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start

__bis_SR_register(GIE); // LPM0, ADC10_ISR will force exit CPUOFF +

P1OUT &= ~0x01; // P1.0 = 0 // delay(25000); }

// ADC10中断服务程序

#pragma vector=ADC10_VECTOR

__interrupt void ADC10_ISR(void)

{ _EINT(); /*static unsigned char index = 0;//静态变量 results[index++] = ADC10SA;//移动ADC结果到results数组ADC10MEM if(index == 5)//是否转换了100次 { index = 0; flag = 1; } */

_BIS_SR(GIE); LPM0_EXIT; // 退出低功耗模式0 ADC10IFG }

//************主函数***************************

void main()

{ WDTCTL = WDTPW + WDTHOLD; // Stop WDT

BCSCTL1 = CALBC1_1MHZ;

DCOCTL = CALDCO_1MHZ;

_DINT() ; //关闭中断

led_init();

timer_init();

_EINT(); //开总中断 _BIS_SR(GIE);

for(;;) { ; } }