Below is my program. The test program can enter interruption, but no data can be collected. Can you help me find the problem? #include #define n 36 int ADC_buf[n]; unsigned char j; unsigned char i=0; int g_zhong,ADC_MAX; float MAX_true; void init_TimerA(void) { TA0CTL|=TASSEL_2+TACLR;//选择时钟为SMCLK,清除TAR TA0CCTL0|=CCIE;;//CCR0使能中断 //TA0CCR0=40000;//频率为200Hz 8M/40000=200 TA0CCR0=20000;//频率为40kHz 8M/200=40k TA0CTL|=MC0;//增计数模式 } void init_ADC(void) { ADC12CTL0&=~ADC12ENC;//允许转换位是零,不允许转换 ADC12CTL1|=ADC12CSTARTADD_0;//多次转换的地址是ADC12MEM0 ADC12MCTL0|=ADC12INCH_0;//模拟输入通道为A0 ADC12CTL0|=ADC12SHT0_8 + ADC12ON;//ADC12ON:ADC12模块转换控制位,为一时打开该模块允许转换, ADC12CTL1|=ADC12CONSEQ_2;//单通道多次转换模式 ADC12CTL1|=ADC12SSEL_2;//ADC12时钟源选择SMCLK ADC12CTL1|=ADC12DIV_0;//分频因子是1 ADC12CTL1|=ADC12SHP;//Sampling signal source comes from timer ADC12CTL1|=ADC12SHS_1;//Clock source selectionTA ADC12CTL0|=ADC12ENC;//ENC: Conversion enable bit is temporarily allowed to be converted, } int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT[/fontsize][/fontsize] ] init_TimerA(); //Clock initialization init_ADC(); P6SEL |= 0x01; // P6.0 ADC option select P1DIR |= 0x01; P1OUT &=~BIT0;[/ align] P6DIR |= BIT1; P6OUT |= BIT1; _EINT(); while (1) { ADC_buf=ADC12MEM0;//读取转换结果 i++; i=i%n; if(i==0) { for(j=1;j" color][="" color][color="#7F0055]if(ADC_buf[j-1]" font][="" size][="" {[="">ADC_buf[j]) { g_zhong=ADC_buf[j-1]; ADC_buf[j-1]=ADC_buf[j]; ADC_buf[j]=g_zhong; } ADC_MAX=ADC_buf[n-1]; } MAX_true=ADC_MAX*3.30/4095; } } } #pragmavector=TIMER0_A0_VECTOR __interrupt void Timer_A(void) { P6OUT^= BIT1; ADC12CTL0|= ADC12ENC+ADC12SC; _bic_SR_register(LPM0_bits); }
|