PIC24F: ADCs taking longer than expected

Thread Starter

Robin66

Joined Jan 5, 2016
281
Hi, I seem to be losing time in my ADCs. They should be taking 12*Tad = 7.5us but it's more like 10us. I have some simple code below that demonstrates the problem. Does anyone have any idea where the extra time is going and whether my sample point is being delayed or if the conversion is just taking longer than 12Tad? I've confirmed that the clock is running at 32MHz.

Code:
    AD1CON3bits.ADCS = 9;  // min.Tad = 600ns, 1FCY period = 62.5ns, therefore 10x = 625ns = 7.5us per 10bit conversion
    AD1CON1bits.ADON = 0; // keep off  
    while(1)
    {
        __delay_ms(2); 
        AD1CON1bits.ADON = 0; // OFF
        AD1CON3bits.SAMC = 0;
        AD1CON1bits.SSRC = 0; // Manual sample control
        AD1CHSbits.CH0SA = 2; // point muxA to AN2
        AD1CON1bits.ADON = 1; // ON
        AD1CON1bits.SAMP = 1;
        __delay_us(2);   // sufficient time to sample
        PROBE1 = 1;
        AD1CON1bits.SAMP = 0;  // start conversion
        while (!AD1CON1bits.DONE)
        {
            PROBE1 = 1;
            PROBE1 = 0;
        }
        PROBE1 = 0;
    }
IMG_5092.JPG
 
Last edited:
Top