# Question regarding Crystal/Oscillator frequency

#### skysurf

Joined Oct 20, 2005
14
Hi,

I have a microcontroller project that I am currently working on. I was currently looking at the oscillator and cpu frequency of the microcontroller and trying to figure out how it works. The microcontroller has an on-chip oscillator, and is connected to an external crystal as the following image:

Apparently, in the source code I received from someone else, it seems that the on-chip oscillator's frequency is 16Mhz. However, the crystal in the image above has a frequence of 8Mhz.

My guess is that the capicatance of C108 & C109 is the reason why the on-chip oscillator's frequency is doubled, is this correct???? Also, is there a formula that I can use to calculate the output frequency of the on-chip oscillator based on these capacitances and the crystal frequency????

Would appreciate any help!!!!

Thanks much!!!!

#### beenthere

Joined Apr 20, 2004
15,819
Hi,

No, that ain't the way it works. You need to look at the spec sheet for your microprocessor, and supply the crystal for the frequency called for. You can run at a lower freq - that's no biggie.

The illo you have is of a typical crystal circuit. The caps are there to shunt off some of the overtones from the crystal, which is a noisy beast. For the majority of applications, 12 pF is the common size for the caps. They can range down to 6 Pf, though. Whatever lets the microprocessor run is good enough.

No formula - the frequency is the one lasered on the crystal's can.

#### skysurf

Joined Oct 20, 2005
14
Hmmmm, guess I am a bit confused then....

Since the crystal is 8Mhz, then that would mean that the on-chip oscillator's frequency is also 8Mhz (before doing any prescaling/multiplying for the actualy CPU frequency), right????

But then how does this guy's source code have a macro defined stating the oscillator frequency is 16Mhz???? I don't think he has made a mistake, since the CPU frequency is supposed to be 40 Mhz (oscillator frequency * 2.5)

Thanks for any help!!!!

#### Papabravo

Joined Feb 24, 2006
20,993
Why are you asking us? Ask the guy who wrote the code, or tell us what processor this is so we can check the datasheet.