void main( void ) { WDTCTL=WDTPW+WDTHOLD; //关看门狗 BCSCTL1 =CALBC1_1MHZ; //设定DCO 为1MHZ DCOCTL =CALBC1_1MHZ; P1SEL=0X01;
P1DIR =0xF4; P1OUT &=~BIT4;//CH = 0; delay(1); init(); delay(10); clearLCD(); //时钟源选AD 内部时钟并4 分频,选通道1.0,AD 启动信号来源选TA.OUT1,选单通道连续采样 ADC10CTL1=ADC10DIV_3+INCH_0+SHS_0+CONSEQ_2; //选1.5V 为正向参考,地为负参考,AD 中断使能,打开参考,启动AD 模块(不shi启动AD 转换) ADC10CTL0=SREF_1+ADC10SHT_3+ADC10IE+REFON+ADC10ON+REF2_5V; ADC10AE0 |= 0x01; // PA.0 ADC option select使p1.0允许AD模拟输入信号 TACCR0=30; //延时等待参考稳定 TACCTL0 |=CCIE; //CCR0 中断使能 TACTL=TACLR+MC_1+TASSEL_2; //TA 增计数,时钟源为smclk _BIS_SR(LPM0_bits+GIE); //进入低功耗0,使能总中断,等待参考稳定 TACCTL0 &=~CCIE; //CCR0 中断禁止 _BIC_SR(GIE); //关总中断 ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start (ADC10开始采样转换) TACCTL1=OUTMOD_4; //CCR1 选输出模式4,当TAR=0 时,输出高电平 TACTL =TASSEL_2+MC_2; //TA 改为连续计数,smclk 时钟源 while(1) { _BIS_SR(LPM0_bits+GIE); //进入低功耗0,使能总中断,等待10AD 完成 if(nn>=127) { wav_display();//波形显示 nn=0; clearLCD(); } _BIS_SR(GIE); } } /*#pragma vector=TIMER0_A0_VECTOR __interrupt void ta0_isr(void) { TACTL = 0; LPM0_EXIT; // Exit LPM0 on return }
*/ #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR(void) { cos[nn]=ADC10MEM; 这里想得到一个128位的数组 输给12864 怎么么老是不行呢!!! nn++; __bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR) }
|