This first thing to do is look in the 18F252 datasheet for the minimum TAD.
Go to the "Electrical Characteristics" section, then search for TAD, you should see this ...

1.6 uS is the minimum TAD.
Simply multiply the main oscillator frequency (in your case 40,000,000) times the minimum TAD (0.0000016).
40,000,000 * 0.0000016 = 64
Always round UP.
If FOSC = 16,000,000 then (16,000,000 * 0.0000016 = 25.6), so you have to round that UP to the closest prescaler (32).
Now go to the "COMPATIBLE 10-BIT ANALOG-TO-DIGITAL CONVERTER (A/D) MODULE" section and look at the ADCON0 and ADCON1 registers.
The ADCS bits select the A/D clock. There are 2 bits in ADCON0 and 1 bit in ADCON1. Together, they make up a 3-bit binary number.
Look that number up in the table for the ADCON0 register ...
For FOSC/64, it's 110

Convert it to decimal and use ...
Code:
DEFINE ADC_CLOCK 6 ; FOSC/64, 1.6uS @ 40Mhz
Different chips have different minimum TAD requirements, and the ADCS bits will change too. Always look them up.
NOTE: If you were using a 16F1 part, the DEFINE ADC_CLOCK has no affect and the ADCONx registers must be set manually.
_____________ ________________________ _____________________
You do not need a PAUSEUS statement for acquisition time.
That's what the DEFINE ADC_SAMPLEUS does.
Exactly how much acquisition time is required is a complicated question that depends on circuit impedance, whether or not you are reading more than one channel and again ... the chip you are using.
mister-e's PicMultiCalc is useful for the impedance part.
If you are only reading 1 channel, you don't need any acquisition time at all.
The Trial and error method usually works well enough though.
Reduce the ADC_SAMPLEUS time until you get bad readings or cross-talk between channels, then double it.
Bookmarks