2
#include <xc.h>
#pragma config FOSC = HS
void main() 
{  
    OSCCONbits.IRCF = 0b111;
    OSCTUNE = 0b01111;
    OSCCONbits.SCS = 0;
    OSCCONbits.OSTS = 1;
    OSCCONbits.HTS = 1;
    OSCCONbits.LTS = 1;
    TRISBbits.TRISA2 = 0;
    ANSELbits.ANS2 = 1;
    ADCON0 = 0x89;
    ADCON1 = 0x00;
    while(1)
    {
        ADCON0bits.GO = 1;
        while(ADCON0bits.GO == 1)
        {
            PORTBbits.RB6 = ~(PORTBbits.RB6);
        }
    }
}

I am struggling to change the adc conversion. When i am checking in the oscilloscope. i am getting the conversion time as 10 micro seconds. but it needs to take like 200 nsec.

MPLAB version 5.40

Pickit 3 programmer

XC8 compiler

General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • 200 ns is instruction cycle of your microcontroller. Check datasheet for minimum adc conversion time! – GJ. Oct 15 '20 at 11:09
  • 250 nano seconds it takes for one bit conversion for 10 bit it takes 2.75 micro seconds but i am getting 11 micro seconds. – saidasaradha Oct 15 '20 at 11:56

1 Answers1

1

The time to complete one bit conversion is defined as Tad. One full 10 bit conversion requires 11 Tad periods. The minimum Tad time is 1.6 us at 20 Mhz, check datasheet TABLE 17-11. If you are using 16 Mhz oscillator than the minimum Tad time is 2 us. So for full 10 bit conversion your ADC need 22 us. But ADC need also some time to charge holding capacitor, check datasheet section 9.2, which is about 2 us or more. As you can calculate the minimum ADC conversion time for PIC16F88x is about 25us at 16 Mhz microcontroller oscillator.

enter image description here

GJ.
  • 10,810
  • 2
  • 45
  • 62