# Am I overclocking a PIC18F4525?

I'm working on a legacy product, so I can't adjust the crystal or board in any way. It was originally written in PicBasicPro and I'm moving things over to Hi-Tech C.

It's a Pic18F4525 and has a 20Mhz crystal. According to the datasheet, the PLL just multiplies the frequency by 4.

So, this would give me a frequency of 20Mhz

__CONFIG(1, HS & IESOEN & FCMEN);


This would give me a frequency of 80Mhz

__CONFIG(1, HSPLL & IESOEN & FCMEN);


Surprisingly, by enabling HSPLL, the serial port outputs correctly, lcd still outputs, other than delay times I didn't see anything break.

So, my question is, what frequency is the clock running? Is it really running 80Mhz with PLL? or does the Hi-Tech C compiler know the max clock speed is 40Mhz and limit it there?

I will probably just stay safe and leave it at 20Mhz, but I would have expected serious problems clocking a 40Mhz chip to 80Mhz and didn't see any.

• Also see Overclocking an AVR - copied below temporarily. Mar 7 '12 at 2:36

No, you can't enable the PLL with a 20 MHz crystal since 80 MHz clock rate is way out of spec. The PIC may appear to work, but there is no guarantee what it might screw up at what time without warning. Overclocking is a no-win game some clueless people engage in that think there is a free lunch to be had. You said "product", so you really really don't want to go there.

• Thanks. I figured it was not a good idea, but was surprised to see it working. Mar 6 '12 at 18:25
• This is a shameless copy of another answer of mine but it's more fun putting it here to be seen. Just putting a link means fewer people will see it and I think it's both fun enough and apposite enough to be posted here like this.

IF you want to upvote this answer [ :-) ] please upvote the copy at here and

I'll delete this answer in due course.
Please leave this live for a few days.

How to make life more interesting 101:

• If you don't care

that your results may sometimes be wrong,
that your system may sometimes crash,
that your life may be more interesting,
that your Segway clone only occasionally does face-plants for no obvious reason,
that ...

then by all means run the part outside manufacturer's spec

You get what you don't pay for.
If you have a $10 head, buy a$10 helmet.

It may often work.
It may not work sometimes.
It may not be obvious that it isn't working sometimes.

• A divide may usually work
• A jump may usually arrive.
• A table may belooked up correctly.
• An ADC value may be correct.

Or not

Final version will be:

Please see my answer at here re "“Overclocking” an AVR" which applies well enough to be well worth looking at, even if I do say so myself :-).

I don't think

__CONFIG(1, HS & IESOEN & FCMEN);


enables the PLL, which is why things are working.

I think you need:

__CONFIG(1, HSPLL & IESOEN & FCMEN);


because in \dat\cfgdata\18f4525.cfgdata, I see:

CVALUE:6:HSPLL:HS oscillator, PLL enabled (Clock Frequency = 4 x FOSC1)
CVALUE:2:HS:HS oscillator

• That's what I have, I had a small typo, it got changed by editing. I'll clarify Mar 6 '12 at 18:15