-
MSP430F169的ADC12采样率问题
求高手点拨。 想要使用单通道连续采样,工作在最高采样率。但是用TI的例程实测,采样率都低太多。 时钟用ADC内部振荡器,约5MHz,2个采样周期+13个转换周期,计算下来应该4us左右采一个点。 但是,输入5kHz的正方波——100us高电平, 采下来高电平就采到2、3个值,低电平采到1、2个值,感觉30多us才采了一个点。 IAR编译,自己画的开发板,代码如下: #include #include "..\com\delay.h" #define Num_of_Results 30 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. static unsigned int index = 0; unsigned char ir; void main(void) { WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer /* for test */ P1DIR |= BIT0; // 上电指示 P1OUT |= BIT0; P2DIR |= BIT6; // ADC12CLK P2SEL |= BIT6; // Vref+ 在pin7测试 P5DIR |= 0x70; // P5.6,5,4 outputs P5SEL |= 0x70; // P5.6,5,4 options, ACLK, SMCLK, MCLK /**/ P6SEL |= 0x01; // Enable A/D channel A0 ADC12CTL0 = ADC12ON + SHT0_2 + REFON + MSC; // Turn on ADC12, set sampling time ADC12CTL1 = SHP + CONSEQ_2; // Use sampling timer, single-repeat mode, default: ADC12CLK = ADC12OSC(about 5MHz) ADC12MCTL0 = SREF_1; // Vr+=Vref+ ADC12IE = 0x01; // Enable ADC12IFG.0 delay_ms(20); ADC12CTL0 |= ENC; // Enable conversions ADC12CTL0 |= ADC12SC; // Start conversion _BIS_SR(LPM0_bits + GIE); // Enter LPM0,Enable interrupts } #pragma vector=ADC12_VECTOR __interrupt void ADC12ISR (void) { results[index] = ADC12MEM0; // Move results index = (index+1)%Num_of_Results; // Increment results index, modulo }
813浏览量 3回复量 关注量