Basic PIC / Oscillator question

Thread Starter

doubledutch1962

Joined Oct 27, 2020
33
I'm trying to build a simple circuit using a PIC16F877A which has no internal oscillator. When I use an RC Oscillator - it works fine. When I try to move to an HS Oscillator (obviously I change the Config bits) it doesn't work.

I suspect that either:

  1. There is an issue with my parts
  2. I need to start soldering as my solderless breadboard configuration introduces too much noise

I would be grateful if someone could confirm the parts below will work or if I need to buy something else

X1 (20.000MHz)

1616060976806.png

C1/C2 (both 30pF)

1616061028262.png

1616057152429.png
 

Thread Starter

doubledutch1962

Joined Oct 27, 2020
33
Man... That was too simple (that did the trick). Apologies I probably should have figured that out myself. I feel very stupid (but wasn't aware that some crystals had capacitors inside)
 

AlbertHall

Joined Jun 4, 2014
11,102
Most crystals don't have internal capacitors, but you can try it without the external capacitors.
20MHz is a high frequency for a solderless breadboard. The crystal and the capacitors should be arranged to have the shortest possible connections to the PIC, including the 0V end of the capacitors.
 

AlbertHall

Joined Jun 4, 2014
11,102
Man... That was too simple (that did the trick). Apologies I probably should have figured that out myself. I feel very stupid (but wasn't aware that some crystals had capacitors inside)
Even if the crystal doesn't have internal capacitors, the capacitance added by the breadboard may be sufficient for the oscillator to work.
 

peterdeco

Joined Oct 8, 2019
330
I use the internal RC oscillator on most PICs or a ceramic resonator on some. Albert has a very good point. Your breadboard might be offering the capacitance needed to oscillate. You really should put your circuit on a PCB.
 

BobTPH

Joined Jun 5, 2013
3,002
Hopefully, you connected the power and ground pins, and included a bypass capacitor, which are not shown in the schematic.

Bob
 

Thread Starter

doubledutch1962

Joined Oct 27, 2020
33
Thanks all - I am going to solder things on a breadboard real soon but wanted to figure out first if I was using the right parts. I learned my lesson with solderless PCB's when I started looking at OpAmps. It's finding the right time to jump from the solderless breadboard to the soldering iron without wasting too many components that I struggle with. I just don't always know (like in this case) if what I'm doing is basically sound. Here it wasn't.
 

upand_at_them

Joined May 15, 2010
760
What crystals have internal capacitors? What datasheet? The crystals above look like everyday normal crystals that do not have internal capacitors. Crystal datasheets will list the expected load capacitance. I would be more inclined that the capacitors were incorrectly connected.
 

atferrari

Joined Jan 6, 2004
4,236
Since when I started with the PIC16C57, I have always used protoboards with good results. Some yes, went to PCBs later.

I always remark that, no matter what frequency, all is occurring inside the micro, not outside in the protoboard.

All my failures wrt clock was in the configuration not in the hardware.

IIRC, the highest clock frequency (PLL) was 48 MHz.
 

peterdeco

Joined Oct 8, 2019
330
You're right UP. I misread the datasheet. It was 20 pf load capacitance. I still side with Albert that the breadboard could have added too much capacitance with the capacitors hooked up. Sorry for the misread. I'm used to my ceramic resonators with 2 internal 30pF caps.
 

Thread Starter

doubledutch1962

Joined Oct 27, 2020
33
Thanks all - and you answered my question:

1) The parts are correct (without capacitors they actually work so it's the capacitance of my breadboard that's the issue)
2) I need to start soldering
 

upand_at_them

Joined May 15, 2010
760
solderless breadboard

Too much capacitance and coupling between everything. It's amazing it works at all at 20 MHz.
Not amazing at all. In the decades of using breadboards I don't think I can recall any incidents of breadboard capacitance causing a problem. And I regularly use PIC's on breadboards at 20MHz. I suspect some people have poor breadboard technique and are doing bad things like long air wires or running wires to crystals and capacitors. There's never any need to use wires for the crystal section; crystal goes into two holes by the uC pins and the two caps bridge the end of the rows to the common ground side column.
 

John P

Joined Oct 14, 2008
1,876
That looked like an ordinary crystal to me, because if the crystal included capacitors, I would expect it to have an additional terminal to connect them to Ground. I'm a little surprised that the breadboard circuit worked without capacitors but failed to work when they were added, but oh well, it's tough to argue with success.
 
Top