View previous topic :: View next topic |
Author |
Message |
tonofit
Joined: 23 Jun 2005 Posts: 4
|
Clock multiplier & ADC conversion |
Posted: Thu Aug 11, 2005 1:06 pm |
|
|
I'm using the 18F8722. The microchip data book for PIC18FXX20 on page 213 show the TAD .vs. Device Operating Frequencies. I have a 10 MHZ xtal to run the PIC. To get the correct voltages I'm having to use a 20 Millisecond delay otherwise I only get a very low partial voltage reading.
Question 1: How do program or set up the 18F8722 to use the multipliers to operate at 40 MHZ?
Question 2: How do I elimnate the need for the 20 milisecond delay besides running at a faster clock rate if any?
The adc settings are:
Code: |
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL | ADC_TAD_MUL_16); // use the internal clock
set_adc_channel(channeladd);
output_low(PIN_H3);
output_low(PIN_H2);
delay_ms(20);
return(read_adc()); |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 11, 2005 2:01 pm |
|
|
There's a table right in the 18F8722 data sheet, in Section 21.3
on Selecting the A/D Conversion Clock.
It says don't use the Internal R/C clock at frequencies greater than
1.00 MHz, unless you're in sleep mode.
The clock divisor must be set so that Tad is greater than or equal
to the minimum value specified in Table 28-27, which is 0.7 us.
(This is less than the traditional minimum of 1.6 us, for older PICs
such as the 16F877).
So if you use a divisor of 32, this will give 40 MHz / 32 = 1.25 MHz,
and the Tad period is then 1/1.25 MHz = 0.8 us. This is greater
than the minimum of 0.7us, so it should work OK.
So you should use "ADC_CLOCK_DIV_32".
The next question is which Tad multiplier to use for the Acquisition time.
I don't know what the component values are in your A/D circuit.
Of course you know that Microchip says the impedance of your A/D
circuit should be a maximum of 2.5K ohms. (It's not 10K ohms like
it was in the 16F877).
I don't know what your acquisition time will be, so let's just use the
maximum. So your setup adc statement should be:
setup_adc(ADC_CLOCK_DIV_32 | ADC_TAD_MUL_20); |
|
|
Guest
|
|
Posted: Thu Aug 11, 2005 3:09 pm |
|
|
Thanks for the reply and the calculation at 40 MHZ. From the data sheet it says the 18F8722 processor is capable of running at 40MHZ.
On my board I'm using the 18F8722 processor running with a 10 MHZ xtal.
Code: |
#use_delay(10000000)
|
How do I mulitply the clock freq to get the 40MHZ freq with a 10MHZ xtal. Is it it just?
Code: |
a #use_delay(40000000)
|
|
|
|
|