CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Clock multiplier & ADC conversion

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
tonofit



Joined: 23 Jun 2005
Posts: 4

View user's profile Send private message

Clock multiplier & ADC conversion
PostPosted: Thu Aug 11, 2005 1:06 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Aug 11, 2005 2:01 pm     Reply with quote

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








PostPosted: Thu Aug 11, 2005 3:09 pm     Reply with quote

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)
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group