也不算问题了,就是自己想不明白,想问问为什么,我用dspic33fj128mc706
进行AD采样,扫描采样方式,由于懒得用DMA,就直接进中断读buf来存数。实验时候采用的是2通道扫描, 我对AD的各个寄存器采用了如下设置
void initadc1()
{
AD1CON1bits.FORM = 0;
// Data Output Format: Signed Fraction (Q15 format)
AD1CON1bits.SSRC = 0; // Sample human
AD1CON1bits.ASAM = 0;
// ADC Sample Control: Sampling begins immediately after conversion
AD1CON1bits.AD12B = 0; // 10-bit ADC operation
AD1CON2bits.CSCNA = 1;
// Scan Input Selections for CH0+ during Sample A bit
AD1CON2bits.CHPS = 0; // Converts CH0
AD1CON3bits.ADRC = 0; // ADC Clock is derived from Systems Clock
AD1CON3bits.ADCS = 63;
AD1CON2bits.SMPI = 1; // 4 ADC Channel is scanned
AD1CSSLbits.CSS4=1; // Enable AN4 for channel scan
AD1CSSLbits.CSS5=1;
// Enable AN5 for channel scan
AD1PCFGL=0xFFFF;
AD1PCFGLbits.PCFG4 = 0; // AN4 as Analog Input
AD1PCFGLbits.PCFG5 = 0; // AN5 as Analog Input
IFS0bits.AD1IF = 0; // Clear the A/D interrupt flag bit
IEC0bits.AD1IE = 1; // Enable A/D interrupt
}
设置采用的是两通道的输入扫描,分别是AN4和AN5,按照手册上说,是每完成两个采用,产生一次中断。可是buf是会被覆盖的啊,按道理说我在中断程序中只能读到采到的一个值,为什么我确实读到了两个呢?究竟是怎么实现的 ?请大神给解答一下~谢啦!! |