Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC18F OSC source - need help

Status
Not open for further replies.

jamwaffles

New Member
hi

im experimenting with a PIC18F4520 in C and i cant get the external oscillator working/disable internal osc. what i need is a ceramic resonator on both external clock pins and the internal osc disabled or some way to make a clock frequency of 20MHz+ either internally or externally. im usign boostc or hi-tech PICC Pro lite blahblahblah, so an example to flash an led at 1hz in either of those compilers would be much appreciated

thanks

james waples, 14
 
You can flash an LED at 1 Hz with the internal oscillator if you set the divide code correctly.

You need to set the configuration bits to HS (High Speed) Oscillator.

Your ceramic resonator will need capacitors to ground at each end. It is easier to buy an external oscillator and connect that to the oscillator input of the PIC.
 
thanks very much. could i have a code sample on how to set the external osc with pll in wither boostc or hi-tech picc (both 18F versions) please. thanks again
 
If you are using an external OSC with PLL you absolutely must have a 0.1uF decoupling capacitor as close to the power pins of the PIC as possible or you will have big problems.

You say you are using a Ceramic Resonator ? Is it a 2 pin or 3 pin ?

If its a 3 pin, make sure the center pin is connected to ground. If its a 2 pin then you will need a capacitor from each OSC pin to ground (consult the datasheet for this but normally something in the range of 22pf seems to work fine).
 
im using a 3pin ceramic resonator at 20MHz and i found a solution around the PLL: i now have 80MHz! the decoupling caps are cos of the high frequencies arent they. i built a PCB with the PIC and a 7805 with 2 0.1 ufs either side. they are about an inch and a half away from the pic physically. would that do anything?
 
The data sheet states a maximum of 40MHz. If you use a 20MHz resonator with the times 4 PLL then you will have an extremely unreliable chip. You should use the HS setting and run at 20MHz or get a 10MHz resonator/crystal to use the PLL.

Is there any reason why 20MHz isn't fast enough?

Mike.
 
As above - trying to run a PIC at 80Mhz via a 20Mhz xtal and 4PLL is a very bad idea.

You decoupling should be adequate though at 40Mhz. I try and get my decoupling caps within 1 inch of the CPU (ideally a lot closer)
 
well, it hasnt died on me yet so i guess its ok. iv also got the osc in a pin header so swapping is quite easy. if i get any news on unstable-ness, ill tell
 
Status
Not open for further replies.

Latest threads

Back
Top